一本通 1281:最长上升子序列

最长上升子序列

#include <iostream>
#include <cstdio>
using namespace std;
//Mystery_Sky
//最长上升子序列 
#define M 1010
int f[M], a[M], n;
int ans;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]), f[i] = 1;
	for(int i = 2; i <= n; i++)
		for(int j = 1; j < i; j++)
			if(a[i] > a[j]) f[i] = max(f[i], f[j]+1);
	for(int i = 1; i <= n; i++) ans = max(ans, f[i]);
	return 0 * printf("%d\n", ans);
}
posted @ 2019-05-01 21:44  Mystery_Sky  阅读(256)  评论(0编辑  收藏  举报