HDU 1087 Super Jumping! Jumping! Jumping!

#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,a[1000],n,temp,s[1000],max;
    while(scanf("%d",&n)!=EOF && n)
    {
        for(i=0;i<n;i++)  scanf("%d",&a[i]);
        max=0;
        memset(s,0,sizeof(s));
        for(i=0;i<n;i++){
            temp=0;     // 到 j 个数时的最大解
            for(j=0;j<i;j++){
                if(a[i]>a[j]){
                    if(s[j]>temp)
                       temp=s[j];
                }           
            }
            s[i]+=a[i]+temp;
            if(max<s[i]) max=s[i];           
        }      
        printf("%d\n",max);              
    }
    return 0;
}

你可能感兴趣的:(ini)