Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12810Accepted Submission(s): 5292
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.
The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In
the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping
can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his
jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.
Input
Input contains multiple test cases. Each test case is described in a line as follow:
N value_1 value_2 …value_N
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.
Output
For each case, print the maximum according to rules, and one line one case.
Sample Input
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
Sample Output
题意:此题就是找序列中最大升序子序列的和。
可跳 不一定非要连续
比如 1 3 2 中升序序列有:{1}{3}{2}{1,3}{1,2}。所以最大为1+3=4;
#include<stdio.h>
__int64 a[1005],sum[1005];
int main()
{
int i,j,n,max,ans;
while(scanf("%d",&n)&&n)
{
for(i=0;i<n;i++)
{scanf("%I64d",&a[i]);sum[i]=a[i];}
ans=0;
for(i=0;i<n;i++)//j比i小
{
for(j=0;j<i;j++)
{ if(a[j]<a[i])
sum[i]=sum[i]>(sum[j]+a[i])?sum[i]:(sum[j]+a[i]);//sum[j]
之前已经求出来了
}
ans=ans>sum[i]?ans:sum[i];
}
printf("%d\n",ans);
}
return 0;
}
分享到:
相关推荐
1001 计算直线的交点数 1002 FatMouse's Speed1003 Common Subsequence1004 Max Sum 1005 Super Jumping! Jumping! Jumping! 1006 免费馅饼 1007 Humble Numbers1008 Monkey and Banana 1009 龟兔赛跑 1010 数塔
杭电ACMhdu1163
hdu1001解题报告
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
HDU1059的代码
hdu 1574 passed sorce
HDU的一题........HDU DP动态规
hdu2101AC代码
hdu acm 教案 搜索入门 hdu acm 教案 搜索入门
搜索 dfs 解题代码 hdu1241
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
自己做的HDU ACM已经AC的题目
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
hdu 1166线段树代码
HDU最全ac代码
hdu动态规划算法集锦
hdu题目分类
ACM HDU题目分类,我自己总结的大概只有十来个吧
Hdu 1237 解题代码
HDU图论题目分类