HDU 1087 Super Jumping! Jumping! Jumping!
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1087
#include <stdio.h> #include <string.h> int dp[1050],x[1050],num[1050]; void main() { int n,i,j,k,max; while(scanf("%d",&n)!=EOF&&n) { memset(dp,0,sizeof(dp)); memset(num,0,sizeof(num)); k=0; for(i=1;i<n+1;i++) { memset(x,0,sizeof(x)); scanf("%d",&num[i]); max=0; for(j=i;j>0;j--) { if(num[i]>num[j-1]) x[j]=j-1; if(dp[x[j]]>max) max=dp[x[j]]; } dp[i]=max+num[i]; if(dp[i]>k) k=dp[i]; } printf("%d\n",k); } }