1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include <iostream> #include <cstring> using namespace std;
int data[1010]; int dp[1010];
int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> data[i]; }
fill(dp, dp+1010, 1);
int ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { if (data[i] > data[j]) { dp[i] = max(dp[i], dp[j] + 1); } } ans = max(ans, dp[i]); }
cout << ans << endl;
return 0; }
|