一本通 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
", ans);
}
唯愿,青春不辜负梦想,未来星辰闪耀
原文地址:https://www.cnblogs.com/Benjamin-cpp/p/10786414.html