1 #include <cstdio> 2 #include <iostream> 3 4 using namespace std; 5 6 const int max_n = 1000 + 2; 7 const int max_a = 1e6 + 10; 8 9 int n; 10 int a[max_n]; 11 int dp[max_n]; 12 13 void solve() 14 { 15 for(int i=1;i<=n;++i) 16 { 17 dp[i]=1; 18 for(int j=1;j<i;++j) 19 { 20 if(a[j]<a[i]) 21 { 22 dp[i]=max(dp[i],dp[j]+1); 23 } 24 } 25 } 26 printf("%d\n",dp[n]); 27 } 28 29 int main() 30 { 31 scanf("%d",&n); 32 for(int i=1;i<=n;++i) 33 { 34 scanf("%d",&a[i]); 35 } 36 solve(); 37 return 0; 38 } 39 40 /*test 41 5 42 4 2 3 1 5 43 44 */
原文地址:https://www.cnblogs.com/jishuren/p/12259571.html
时间: 2024-12-01 19:35:15