地址:http://acm.hdu.edu.cn/showproblem.php?pid=1257
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn = 3e4+10; typedef long long ll; ll a[maxn]; ll dp[maxn]; int main() { ll n; while(cin>>n) { for(int i=0;i<n;i++) cin>>a[i]; for(int i =0 ; i< n;i++) dp[i]=1; ll maxx=-1; for(int i = 1;i<n;i++) { for(int j = 0 ; j < i ; j++) { if(a[i]>a[j]) { dp[i]=max(dp[i],dp[j]+1); //还是之前的思想,选或者不选 } } maxx=max(dp[i],maxx); } cout<<maxx<<endl;} }
原文:https://www.cnblogs.com/liyexin/p/12683109.html