#include<bits/stdc++.h> using namespace std; int dfs (int); int max (int,int); int maxn=0,n,a[10000],f[10000]; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=n;i++) if(dfs(i)>maxn) maxn=f[i]; cout<<maxn; return 0; } int dfs(int i) { if(f[i]>0) return f[i]; f[i]=0; for(int j=i+1;j<=n;j++) if(a[i]<a[j])f[i]=max(f[i],dfs(j)); f[i]++; return f[i]; } int max(int x,int y){ if(x>=y) return x; else return y; }
标签:10000,int,下降,maxn,序列,return,最长 From: https://www.cnblogs.com/xdzxsuming/p/16728667.html