wanmingxing @ 2024-12-09 21:58:10
求代码
by XIAOHAOYU1 @ 2024-12-12 20:56:17
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10005],l[10005];
int main()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) l[i]=1;
for(int i=n;i>=1;i--){
for(int j=i+1;j<=n;j++){
if(a[j]>a[i]){
l[i]=max(l[i],l[j]+1);
}
}
}
int ans=0;
for(int i=1;i<=n;i++) ans=max(l[i],ans);
cout<<ans;
return 0;
}
勿抄
如果不会dp基础建议从dfs->记忆化,再学dp