提交时间:2024-03-30 15:17:25
运行 ID: 140441
#include<bits/stdc++.h> using namespace std; int n,longest=1,a[100001],dp[100001]; int 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;i<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; }