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

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

Super Jumping! Jumping! Jumping!

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5   Accepted Submission(s) : 1
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
4
10
3
 

 

Author
lcy
 这道题,开始没怎么看懂,以为是连续的升段和,怎么这么简单,然后错了2边,后来发现是可以这样重组的....
3 1 3 2 升段有{1},{3},{2},{1,3},{1,2}...所以最大是 4
再比如 7 3 2 1 2 3 4 7  最大值为{1 2 3 4 7}=17.....这样话,关键是如何遍历找到他们的每一个数,对应的最大升段和....
百度百科里有着一个公式;
1 for(i=0;i
arr[j]&&dp[j]>temp) 7 temp=dp[j]; 8 } 9 dp[i]=temp+arr[i];10 }

 

上面的公式,运用的范围极为广泛....注意记下来!!

代码如下:

1 #include
2 #include
3 using namespace std; 4 int main() 5 { 6 int n,i,j,temp; 7 while(cin>>n,n) 8 { 9 vector
arr(n,0);10 vector
dp(n,0);11 for(i=0;i
>arr[i];14 }15 int max=0;16 for(i=0;i
arr[j]&&dp[j]>temp)22 temp=dp[j];23 }24 dp[i]=temp+arr[i];25 26 max=max>dp[i]?max:dp[i];27 }28 cout<
<
View Code

 

 

 

转载于:https://www.cnblogs.com/gongxijun/p/3239226.html

你可能感兴趣的文章
10 华电内部文档搜索系统 search03
查看>>
[HIHO1149]回文字符序列(dp)
查看>>
[HDU1402]A * B Problem Plus(FFT)
查看>>
[CF803C] Maximal GCD(gcd,贪心,构造)
查看>>
逆时针旋转的矩阵变换
查看>>
第10周15/16/17
查看>>
【数据库】SQL两表之间:根据一个表的字段更新另一个表的字段
查看>>
四六级作文常见错误解析(转载)
查看>>
Tomcat
查看>>
./是当前目录 ../是当前的上一级目录。上上级就是../../一般绝对路径时候常用...
查看>>
linux支持FTP和SFTP服务【1】
查看>>
树的递归与非递归遍历方法
查看>>
每天一个Linux命令(6):rmdir命令
查看>>
oracle连接的三个配置文件(转)
查看>>
Vim配置文件(Vimrc)
查看>>
RecyclerView 局部刷新(获取viewHolder 去刷新)
查看>>
PHP表单(get,post)提交方式
查看>>
使用vbs或者bat脚本修改IE浏览器安全级别和选项
查看>>
Silverlight入门
查看>>
Silverlight动态调用WEBSERVICE,WCF方法
查看>>