3 1 3 2 4 1 2 3 4 4 3 3 2 1 0
4 10 3
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int a[1001]; int sum[1001]; int max(int a,int b) { return a>b?a:b; } int main() { int n,i,j,maxs; while(~scanf("%d",&n),n) { memset(a,0,sizeof(a)); memset(sum,0,sizeof(sum)); for(i=0;i<n;i++) scanf("%d",&a[i]); maxs=sum[0]=a[0]; for(i=0;i<n;i++) { sum[i]=a[i]; for(j=0;j<i;j++) { if(a[i]>a[j]) { sum[i]=max(sum[j]+a[i],sum[i]); } } maxs=max(maxs,sum[i]); } printf("%d\n",maxs); } return 0; }
杭电 1087 Super Jumping! Jumping! Jumping!,布布扣,bubuko.com
杭电 1087 Super Jumping! Jumping! Jumping!
原文:http://blog.csdn.net/u012766950/article/details/38276841