提交时间:2024-03-30 15:11:51
运行 ID: 140418
#include<bits/stdc++.h> using namespace std; int main(){ /* 方程:dp[i] = max{dp[j]} + 1 */ int i,j,a[100005],dp[100005],n; int l = 1; cin>>n; for(i = 1;i <= n;i++){ cin>>a[i]; dp[i] = 1; } for(i = 2;i <= n;i++){ for(j = 1;j < i;j++){ if(a[j] <= a[i] && dp[j] + 1 > dp[i]){ dp[i] = dp[j] + 1; l = max(dp[i],l); } } } cout<<l<<endl; }