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位结尾的递增子 ...
随机推荐
- Ubuntu 14.04LTS Gnome GUI初体验及163更新源配制
Ubuntu 14.04 LTS于前天(2014.4.17)公布, 我今天将我的系统升级到最新, 体验了下最新的UI系统. 我选择了Ubuntu Gnome 的GUI界面.我曾经的系统是12.04lt ...
- 表likp新增第一次过账输入日期字段,vl02n/vl01n/vl03n/vl06o的增强
在程序:MV50AFZ1的 FORM USEREXIT_SAVE_DOCUMENT_PREPARE. *begin of ADD CRQ000000012135 CAIZJIAN 2014/3/25( ...
- MS Server中varchar与nvarchar的区别
很多时候我们在创建数据库时在给字段设置数据类型时会选择varchar或是nvarchar.当然还可以选择别的数据类型,本文只对varchar和nvarchar两种类型做说明.如下测试表Test的表结构 ...
- 终于懂了:TWinControl.DefaultHandler里的CallWindowProc(FDefWndProc)还挺有深意的,TButton对WM_PAINT消息的处理就是靠它来处理的(以前不明白为什么总是要调用inherited,其实就是没有明白TWinControl.DefaultHandler的真正用处)
我忽然发现:TButton既没有处理WM_PAINT,又没有Paint()或者PaintWindow(),那么它是什么时候被绘制的? Form1上放2个TButton,然后设置代码: procedur ...
- NumberFormat 类
NumberFormat 表示数字的格式化类, 即:能够依照本地的风格习惯进行数字的显示. 此类的定义例如以下: public abstract class NumberFormat extends ...
- Qt+gsoap调用WebService
1. 前言 Qt本身给我们提供了调用WebService的解决方案qsoap,看了一下他的介绍,感觉实在是太弱了,而且又是个新出的东西,所以还是决定不用他.既然使用Qt,那当然是跨平台的解 ...
- hdu1392 Surround the Trees 凸包
第一次做凸包,这道题要特殊考虑下,n=2时的情况,要除以二才行. 我是从最左边的点出发,每次取斜率最大的点,一直到最右边的点. 然后从最左边的点出发,每次取斜率最低的点,一直到最右边的点. #incl ...
- Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)
题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...
- Oracle 12C 简介
2013年6月26日,Oracle Database 12c版本正式发布,首先发布的版本号是12.1.0.1.0,率先提供下载的平台有Linux和Solaris: Oracle官方下载地址: http ...
- 使用gulp创建ajax模拟请求
概述 之前一直使用gulp构建前端项目,这个基于node流并崇尚“编程而非配置”的工具让我深深的爱上了他.强大的gulp能做到的不仅仅是压缩和合并js.css,它能做到的还有更多.今天我给大家带来使用 ...