HDU 1087 Super Jumping! Jumping! Jumping!
#include"stdio.h"
int b[1000];
int f[1000];
int main(){
//freopen("in.txt","r",stdin);
int n,i,j,temp;//temp 存最大的f[i]
while(scanf("%d",&n),n){
for(i = 0; i < n; i++){
scanf("%d",&b[i]);
f[0] = b[0];//第一个数
temp = -1;
for(j = 0; j < i; j++){
if(b[j] < b[i] && temp < f[j]){
temp = f[j];
}
}
if(temp == -1)
f[i] = b[i];
else
f[i] = temp + b[i];
}
j = f[0];
for(i = 1; i < n; i++){
if(j < f[i])
j = f[i];
}
printf("%d\n",j);
}
return 0;
}