博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Super Jumping! Jumping! Jumping!
阅读量:4916 次
发布时间:2019-06-11

本文共 2094 字,大约阅读时间需要 6 分钟。

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 24 1 2 3 44 3 3 2 10

Sample Output

4103
 
#include 
#include
#include
using namespace std;const int maxn=1002;int num[maxn],sum[maxn];int main(){ int n,i,j,ans; while(scanf("%d",&n)!=EOF&&n) { for(i=1;i<=n;i++) scanf("%d",&num[i]); sum[1]=num[1]; ans=sum[1]; for(i=2;i<=n;i++) { sum[i]=num[i]; for(j=1;j
sum[i]) sum[i]=sum[j]+num[i]; } if(ans

 

转载于:https://www.cnblogs.com/lsb666/p/5767274.html

你可能感兴趣的文章
Java NIO系列教程(十一) Pipe
查看>>
串口屏的特点和开发步骤 + 最好的串口屏产品推荐 .....!
查看>>
蓝桥校内选拔赛B题(不一定正确)
查看>>
数据验证
查看>>
JAVAWeb---HttpServletResponse中的方法
查看>>
一个不错的界面原型制作工具(Balsamiq Mockups)
查看>>
通过eclipse的egit插件提交提示Auth fail
查看>>
对象序列化
查看>>
UVA 208 Firetruck (DFS+剪枝)
查看>>
windows设置电脑的固定IP
查看>>
Python
查看>>
犀牛Phinoceros 如何切换中文语言
查看>>
Win7如何解决精简版的迅雷7无法运行
查看>>
C#.NET常见问题(FAQ)-如何判断某个字符是否为汉字
查看>>
直接用postman测试api ,服务器端没提供跨域也可以访问。
查看>>
数据的类型以及内置方法
查看>>
继承之super关键字的使用
查看>>
XML - 报表数据的新大陆
查看>>
echart在X轴下方添加字
查看>>
Map集合的两种取出方式
查看>>