标签:取值 style problem max code 一个 int 就是 span
1 for (int i = 1;i <= n;i++) 2 for (int j = 1;j <= i-1;j++) 3 { 4 if (a[j]<a[i]) 5 dp[i] = max(dp[j]+1,dp[i]); 6 }
完整代码:
1 #include <cstdio> 2 #include <iostream> 3 using namespace std; 4 int dp[1010]; 5 int main() 6 { 7 int n; 8 int a[1010]; 9 scanf ("%d",&n); 10 int dp[1010]; 11 for (int i = 1;i <= n;i++) 12 { 13 scanf ("%d",&a[i]); 14 dp[i] = 1; 15 } 16 for (int i = 1;i <= n;i++) 17 for (int j = 1;j <= i-1;j++) 18 { 19 if (a[j]<a[i]) 20 dp[i] = max(dp[j]+1,dp[i]); 21 } 22 int ans=0; 23 for (int i =1 ;i <= n;i++) 24 ans=max(dp[i],ans); 25 cout<<ans; 26 return 0; 27 }
标签:取值 style problem max code 一个 int 就是 span
原文地址:https://www.cnblogs.com/very-beginning/p/12001046.html