边输入边更新就行
#include<bits/stdc++.h>
using namespace std;
const int N = 1117;
int num[N], f[N], n, M;
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> num[i];
f[i] = 1;
for(int j = 1; j <= i; j ++)
if(num[j] < num[i] && f[j] + 1 > f[i]) f[i] = f[j] + 1, M = max(M, f[i]);
}
cout << M;
}