Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
#include <stdio.h> int a[1001],b[1001]; int n; int main() { int i,j,tmax,res; while (~scanf("%d",&n)) { if(n==0) break; for (i=0;i<n;i++) { scanf("%d",&a[i]); b[i]=-1; } res=-1; for (i=n-1;i>=0;i--) { tmax=0; for (j=i+1;j<n;j++) { if(a[j]>a[i]&&b[j]>tmax) tmax=b[j]; } b[i]=a[i]+tmax; res=res>b[i]?res:b[i]; } printf("%d\n",res); } }
本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/05/09/2491331.html,如需转载请自行联系原作者