标签:
Description
1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 using namespace std;
7 int main()
8 {
9 int n,a[1005],dp[1005],i,j,k,ans,max;
10 while(cin>>n&&n)
11 {
12 memset(dp,0,sizeof(dp));
13 for(i=0;i<n;i++)
14 cin>>a[i];
15 for(i=0;i<n;i++)
16 {
17 max=0;
18 for(j=0;j<i;j++)
19 {
20 if(a[j]<a[i])
21 {
22 max=max>dp[j]?max:dp[j];
23 }
24 }
25 dp[i]=max+a[i];
26 }
27 ans=0;
28 for(i=0;i<n;i++)
29 ans=ans>dp[i]?ans:dp[i];
30 cout<<ans<<endl;
31 }
32 return 0;
33 }
Super Jumping! Jumping! Jumping!杭电1087
标签:
原文地址:http://www.cnblogs.com/WHLdbk/p/5699879.html