题意:求最长上升子序列长度
思路:做了起码三四次了,取dp[i]为i之前递增子序列长度,求这些长度最大值即可
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn = 100005;
int dp[maxn], a[maxn], n;
int main()
{
while (cin >> n) {
for (int i = 0; i < n; i++)
cin >> a[i];
int maxx = 1;
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (a[i] > a[j]) {
dp[i] = max(dp[i], dp[j]+1);
}
maxx = max(dp[i], maxx);
}
}
cout << maxx << endl;
}
return 0;
}