标签:
dp[j] = max(dp[k]+1,dp[j])(0<k<j&a[j]>a[k])
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <stack> #include <queue> #include <algorithm> using namespace std; const int inf = (1<<31)-1; const int MAXN = 5e5+10; int dp[MAXN]; int a[MAXN]; int main() { int n; int mmax; while(~scanf("%d",&n)){ memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) scanf("%d",&a[i]); dp[1] = 1; mmax = 1; for(int i=2;i<=n;i++){ for(int j=1;j<i;j++){ if(a[i]>a[j]){ dp[i] = max(dp[j]+1,dp[i]); } } mmax = max(mmax,dp[i]); } cout<<mmax<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/EdsonLin/p/5373220.html