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

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

Super Jumping! Jumping! Jumping!

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
 

题意   求n个数字的和最大的递增子序列

基础的dp题目  令d[i]表示以第i个数字结尾的和最大的递增子序列  有d[i]=max(d[i],d[j]+a[i]) j为1到a之间的数  且a[i]>a[j]

#include
#include
using namespace std;const int N = 1005;int a[N], d[N];int main(){ int ans,n; while (scanf ("%d", &n), n) { ans=0; for (int i = 1; i <= n; ++i) { scanf ("%d", &a[i]); d[i]=a[i]; for(int j=1;j
a[j]) d[i]=max(d[i],d[j]+a[i]); ans=max(ans,d[i]); } printf("%d\n",ans); } return 0;}

转载于:https://www.cnblogs.com/acvay/p/3947296.html

你可能感兴趣的文章
对象内存布局 (9)
查看>>
IOS第11天(4:UIDatePicker时间选择,和键盘处理,加载xib文件,代理模式)
查看>>
Delphi XE开发 Android 开机自动启动
查看>>
Delphi中Format与FormatDateTime函数详解
查看>>
c#数据库连接池
查看>>
hdu-5992 Finding Hotels(kd-tree)
查看>>
Alfresco 4 项目介绍
查看>>
[Database] 不知道表名和字段查找值=1234的数据.
查看>>
MySQL的高可用实现:MySQL系列之十四
查看>>
python之os模块
查看>>
重写FileUpload控件让它可以显示上传后的文件名
查看>>
SSO单点登录解决方案[转载]
查看>>
使用闭包跨域开发
查看>>
SourceTree下载与安装 ---记录一下,如果忘记了再拿来看看
查看>>
关于WP7上音乐播放的嫉妒恶心的一些规则和解决方案。
查看>>
JWT(JSON Web Token) 多网站的单点登录,放弃session 转载https://www.cnblogs.com/lexiaofei/p/7409846.html...
查看>>
JAVAWEB 一一 Spirng(AOP面向切面)
查看>>
审计 6 SSRF和任意文件读取
查看>>
eslint 报error
查看>>
java实现微信支付
查看>>