hdu 1087 最长子序列
#include<stdio.h>
int str[1001],sum[1001];
int main()
{
int n,i,max;
//freopen("e://2.txt","r",stdin);
while(scanf("%d",&n)!=EOF&&n)
{
scanf("%d",&str[0]);
sum[0]=str[0];
for(i=1;i<n;i++)
{
scanf("%d",str+i);
max=0;
for(int j=0;j<i;j++)
if(str[i]>str[j]&&max<sum[j])
max=sum[j];
sum[i]=max+str[i];
}
int lmax=-1;
for(i=0;i<n;i++)
if(lmax<sum[i]) lmax=sum[i];
printf("%d\n",lmax);
}
return 0;
}
Just a little, maybe change the world