1.状态表示
2.集合:所有以i个数结尾的上升子序列
3.属性:Max
4.状态计算
#include <iostream>
using namespace std;
const int N = 1010;
int n;
int f[N], a[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
int res = 0;
for (int i = 1; i <= n; i ++)
{
f[i] = 1; //只有一个元素
for (int j = 1; j < i; j ++)
{
if (a[i] > a[j])
f[i] = max(f[i], f[j] + 1);
}
res = max(res, f[i]);
}
cout << res << endl;
return 0;
}