hdu 1087 Super Jumping! Jumping! Jumping!
1 #include<stdio.h> 2 #include<string.h> 3 int a[1001],m[1001]; 4 int main() 5 { 6 int i,j,n,ans,res; 7 while(scanf("%d",&n),n){ 8 memset(m,0,sizeof(m)); 9 for(i=0;i<n;++i) 10 scanf("%d",&a[i]); 11 for(i=0;i<n;++i) { 12 for(ans=j=0;j<i;++j) 13 if(a[j]<a[i]&&ans<m[j]) 14 ans=m[j]; 15 m[i]=ans+a[i]; 16 m[n]=m[n]>m[i]?m[n]:m[i]; 17 } 18 printf("%d\n",m[n]); 19 } 20 }