HDU1087:Super Jumping! Jumping! Jumping!(DP)
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.
4 1 2 3 4
4 3 3 2 1
0
10
3
题意:其实就是最大递增子段和
思路:状态方程:sum[j]=max{sum[i]}+a[j]; 其中,0<=i<=j,a[i]<a[j]
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int a[1005],dp[1005];
const int inf = 999999999; int main()
{
int n,i,t,m,j,ans;
while(~scanf("%d",&n),n)
{
memset(dp,0,sizeof(dp));
for(i = 1;i<=n;i++)
scanf("%d",&a[i]);
for(i = 1;i<=n;i++)
{
ans = -inf;
for(j = 0;j<i;j++)
{
if(a[i]>a[j])
ans = max(ans,dp[j]);
}
dp[i] = ans+a[i];
}
ans = -inf;
for(i = 0;i<=n;i++)
{
if(dp[i]>ans)
ans = dp[i];
}
printf("%d\n",ans);
} return 0;
}
HDU1087:Super Jumping! Jumping! Jumping!(DP)的更多相关文章
- HDU1087 Super Jumping! Jumping! Jumping! —— DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limi ...
- 【HDU - 1087 】Super Jumping! Jumping! Jumping! (简单dp)
Super Jumping! Jumping! Jumping! 搬中文ing Descriptions: wsw成功的在zzq的帮助下获得了与小姐姐约会的机会,同时也不用担心wls会发现了,可是如何 ...
- hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 解题报告 HDU1087 Super Jumping! Jumping! Jumping!
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDU1087 Super Jumping! Jumping! Jumping! 最大连续递增子段
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- kuangbin专题十二 HDU1087 Super Jumping! Jumping! Jumping! (LIS)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 杭电1087 Super Jumping! Jumping! Jumping!(初见DP)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu1087 Super Jumping! Jumping! Jumping!---基础DP---递增子序列最大和
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意: 求递增子序列最大和 思路: 直接dp就可以求解,dp[i]表示以第i位结尾的递增子 ...
随机推荐
- OCP-1Z0-042-V12.39-47题
47.Which two database operations can be performed at the mount stage of database startup? 题目解析: A和E在 ...
- vc怎么去掉烦人的“驱动器未准备好”错误
在我们写程序的时候,如果访问一个软驱中没有软盘或者光驱中没有cd的时候,windows总是弹出一个恼人的错误框说“驱动器未准备好” 其实我们可以通过如下的步骤禁止这个错误框的弹出 一.用SetErro ...
- [置顶] js中如何复制一个对象,如何获取所有属性和属性对应的值
在js中如何复制一个对象,例如如下一个js对象. 如果知道这个对象的所有属性自然就可以重新new一个,然后对每个属性赋值,就可以做到,但如果不知道呢?如何创建一个内容相同 的对象呢? var obj= ...
- Android - 设置adb的usb连接配置
设置adb的usb连接配置 本文地址: http://blog.csdn.net/caroline_wendy 把须要測试的手机连接入电脑.通过系统查找USB连接配置,找到厂商ID: 把ID加入进ad ...
- 10个优秀的 HTML5 & CSS3 下拉菜单制作教程
下拉菜单是一个非经常见的效果.在站点设计中被广泛使用.通过使用下拉菜单.设计者不仅能够在站点设计中营造出色的视觉吸引力,但也能够为站点提供了一个有效的导航方案.使用 HTML5 和 CSS3 能够更e ...
- 表likp新增第一次过账输入日期字段,vl02n/vl01n/vl03n/vl06o的增强
在程序:MV50AFZ1的 FORM USEREXIT_SAVE_DOCUMENT_PREPARE. *begin of ADD CRQ000000012135 CAIZJIAN 2014/3/25( ...
- Friends
Description Mike has many friends. Here are nine of them: Alice, Bob, Carol, Dave, Eve, Frank, Glori ...
- VS2008下编译BOOST 1.39的ASIO库
由于全部编译BOOST库需要的时间太长,而且耗费空间,况且我只需要用ASIO库,所以就没有必要全部编译了. boost库到www.boost.org上下载. 编译很简单,假设你的boost存放的目录是 ...
- javascript json格式解析方法
json.parse用于从一个字符串中解析出json对象 stringify()用于从一个对象解析出字符串 var dataObj = eval("("+json+")& ...
- mysql基础:列类型--整型
mysql列类型--字符串 http://blog.csdn.net/jk110333/article/details/9342301 mysql列类型--时间和日期 http://blog. ...