Super Jumping! Jumping! Jumping!

http://acm.hdu.edu.cn/showproblem.php?pid=1087

View Code
 1 #include<stdio.h>
 2 #include<math.h>
 3 int a[1100], dp[1100] ;
 4 int main()
 5 {
 6     int n, i, j, max , m ;
 7     while(scanf("%d", &n),n!=0)
 8     {
 9         for(i=0; i<n; i++)
10         scanf("%d", &a[i]) ;
11         dp[0] = 0 ;
12         for(i=0; i<n; i++)
13         {
14             m = 0;
15             for(j=0; j<i; j++)
16             if(a[i]>a[j]&&dp[j]>m)
17             m = dp[j] ;
18             dp[i] = m + a[i] ;
19         }
20         max = dp[0] ;
21         for(i=1; i<n; i++)
22         {
23             if(max<dp[i])
24             max = dp[i] ;
25         }
26         printf("%d\n", max) ;
27     }
28     return 0 ;
29 }

 

posted @ 2013-01-30 20:00  yelan@yelan  阅读(108)  评论(0编辑  收藏  举报