提交时间:2024-03-30 15:12:35

运行 ID: 140423

#include<bits/stdc++.h> using namespace std; int a[100010],dp[100010],n;//七十分代码 int longest = 1; signed main(){ cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i]; dp[i] = 1; } for(int i = 2;i <= n;i++){ for(int j= 1;j < i;j++){ if(a[j] <= a[i]&&dp[j]+1>dp[i]) dp[i] = dp[j]+1; longest = max(dp[i],longest); } } cout << longest; return 0; }