hdu 1087
2016-03-14 18:39
190 查看
Super Jumping! Jumping! Jumping!
[b]Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30593 Accepted Submission(s): 13705
[/b]
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, print the maximum according to rules, and one line one case.
[align=left]Sample Input[/align]
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
[align=left]Sample Output[/align]
4
10
3
[align=left]Author[/align]
lcy
[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 1003 1176 1069 1058 1203
好久没有做dp题目,遇到这个经典题目竟然没有思路。
代码如下:
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int N=1005; int ch ,dp ; int main() { int n,Max; while(~scanf("%d",&n)&&n) { for(int i=0;i<n;i++) { scanf("%d",&ch[i]); } dp[0]=Max=ch[0]; for(int i=1;i<n;i++) {//dp[i]代表以ch[i]结尾的最大分数 dp[i]=ch[i]; for(int j=0;j<i;j++) { if(ch[j]<ch[i]) { dp[i]=max(dp[i],dp[j]+ch[i]); } } if(dp[i]>Max) { Max=dp[i]; } } printf("%d\n",Max); } return 0; }
相关文章推荐
- ViewPager,RadioGroup,FragmentManager 详解 <二> 主菜单 RadioGroup 和ViewPager 实现联动
- C中字符结尾‘\0’的作用
- flashbuilder发布release版本
- BASE64原理
- NSBundle
- Youku iOS笔试题
- 跨服务器上传文件
- 如何点击一个图标进入一个网页
- 苹果系统里面部署ASP.NET
- Android 开发过程中需要注意的细节(一)
- 将多个txt文件合并成一个
- 插入排序
- 多国语言文档识别 ABBYY FineReader Corporate v12.0.101.388.7z 绿色破解版
- 自定义特性验证数据
- zookeeper集群搭建
- LeetCode332. Reconstruct Itinerary
- latex 基本用法(四)
- PHP 批量生成静态文件目录代码
- 编程规范的一些小事
- js判断浏览器类型