提交时间:2024-04-06 09:34:14

运行 ID: 141660

#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 005; int a[N], dp[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; dp[1] = 1; for (int i = 1; i <= n; i++) for (int j = 1; j < i; j++) if (a[i] <= a[j]) dp[j] = max(dp[j], dp[i] + 1); int maxn = 0; for (int i = 1; i <= n; i++) maxn = max(maxn, dp[i]); cout << maxn + 1 << endl; return 0; }