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

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

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.

InputInput 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.
OutputFor 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
 
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 int dp[1005]; 7 int main() 8 { 9 int n;10 while(cin>>n)11 {12 if(n==0) break;13 int num[1005];14 num[0]=0;15 for(int i=1;i<=n;i++)16 cin>>num[i];17 memset(dp,0,sizeof(dp));18 for(int i=1;i<=n;i++)19 {20 for(int j=i-1;j>=0;j--)21 {22 if(num[i]>num[j])23 dp[i]=max(dp[i],dp[j]+num[i]);24 }25 }26 int mx=0;27 for(int i=1;i<=n;i++)28 mx=max(mx,dp[i]);29 cout<
<
 

 

 
 

转载于:https://www.cnblogs.com/ISGuXing/p/7257692.html

你可能感兴趣的文章
Ubantu下安装jdk 教程
查看>>
ActiveMQ入门实例
查看>>
手机monkey测试BUG重现及解决方法
查看>>
linux安装至少有哪两个分区,各自作用是什么?
查看>>
转载: 数据库索引原理和优缺点
查看>>
swoole 安装和简单实用
查看>>
文件系统 第八次迭代 VFS相关说明
查看>>
InfoPi运行机制介绍
查看>>
速读《构建之法:现代软件工程》提问
查看>>
SpringCloud注册中心环境搭建euraka
查看>>
各类文件的文件头标志
查看>>
第四周作业——在你的实际项目旅游网站中,网页主页面主要有哪些模块?
查看>>
基于django的个人博客网站建立(一)
查看>>
ElasticSearch 安装使用
查看>>
使用nodejs创建加入用户验证的websocket服务
查看>>
反思最近这些时日的荒废
查看>>
React性能分析利器来了,妈妈再也不用担心我的React应用慢了(转)
查看>>
cocos2dx新建android项目lib拷贝、访问权限等问题集
查看>>
软工学习记3
查看>>
信息安全管理(1):组织的三个层面
查看>>