hdu 1087 最长子序列

来源:互联网 发布:linux中安装oracle11g 编辑:程序博客网 时间:2024/06/08 03:41
#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;
}