HDU - 1087
来源:互联网 发布:开发图形化编程软件 编辑:程序博客网 时间:2024/06/07 10:23
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 Sample Output
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.
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.
3 1 3 24 1 2 3 44 3 3 2 10
4
10
3
#include<stdio.h>main(){ int nax,mmax,i,l,n,qian1[1050],qian2[1050];//qian1数组用来存储输入的每个数值,qian2数组用来存储到达当前位置走过的数值之和的最大值 while(scanf("%d",&n)&&n!=0) { mmax=0; for(i=0;i<n;i++) {scanf("%d",&qian1[i]);qian2[i]=qian1[i];} for(i=0;i<n;i++) { nax=qian2[i]; for(l=0;l<i;l++) { if(qian1[l]<qian1[i]&&qian2[l]+qian1[i]>nax) nax=qian1[i]+qian2[l]; qian2[i]=nax; } if(mmax<nax) mmax=nax; }printf("%d\n",mmax); }}
1 0
- HDU 1087
- hdu 1087
- hdu 1087
- HDU 1087
- hdu 1087
- hdu 1087
- hdu 1087
- hdu 1087
- HDU 1087
- hdu 1087
- hdu 1087
- hdu 1087
- HDU 1087
- hdu-1087
- hdu 1087
- hdu 1087
- HDU 1087
- HDU-1087
- Unity4.6及4.3源码分享
- 突如其来的想法--淘宝店就在我身边,该有多好?
- ES6是什么?
- 爱理财boss系统运行速度调优
- java使用poi读取xls格式和xlsx格式的excel文件
- HDU - 1087
- 登录app后,拍摄图片后自己裁剪头像图片
- 清空git缓存
- 2017.2.17总结
- king of world解释
- 景点商城上云端,才能贴近用户的心情
- 12 关于端点(Endpoint)、簇(clusterId)以及规范(ProfileID)
- 推荐系统--教程两个讲义PPT一个小文档
- js实现16进制颜色转换成rgba格式