状态表示: dp[i] : 以i结尾的最长序列
状态计算:
#include<iostream>
using namespace std;
const int N = 1010;
int a[N];
int dp[N];
int n;
int res = 0;
int main()
{
cin >> n;
for (int i = 1; i <= n ; i ++) cin >>a[i];
for (int i = 1; i <=n; i ++)
{
dp[i] = 1;
for(int j = 1; j < i; j ++)
{
if (a[j] < a[i])
{
dp[i] = max(dp[i], dp[j] + 1);
res = max(res, dp[i]);
}
}
}
cout << res;
}