您的位置:首页 > 其它

HDU 1087 Super Jumping! Jumping! Jumping!【最大递增子段和】

2012-03-14 17:40 288 查看
Problem Description
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.

View Code

#include<stdio.h>
int main()
{
int i,j,n,max,tot;
int a[1001];
int sum[1001];
while(scanf("%d",&n),n)
{
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(j=tot=0;j<n;j++)
{
for(i=max=0;i<=j;i++)
if(a[i]<a[j])
{
if(sum[i]>max)
max=sum[i];
}
sum[j]=max+a[j];
if(sum[j]>tot)
tot=sum[j];
}
printf("%d\n",tot);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐