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位结尾的递增子 ...
随机推荐
- 重操JS旧业第五弹:函数
函数在任何编程语言中起着非常重要的位置,因为他是功能的最小单元,在js中函数是一种类型 Function 1 申明与定义 显示声明:function cc(){};函数名其实是函数的一个指针,函数名某 ...
- Qt调用摄像头(截取并保存图片)
原地址:http://blog.csdn.net/liang19890820/article/details/12782531 Qt如何调用系统摄像设备进行显示.截图.录制? QCamera: ...
- [Java Performance] 数据库性能最佳实践 - JPA缓存
JPA缓存(JPA Caching) JPA有两种类型的缓存: EntityManager自身就是一种缓存.事务中从数据库获取的和写入到数据库的数据会被缓存(什么样的数据会被缓存.在后面有介绍).在一 ...
- [课堂实践与项目]IOS只能进行简单的加减乘除的没有优先级的计算器
// // LCViewController.m // calculator // // Created by lichan on 13-12-3. // Copyright (c) 2013年 co ...
- Mfc资源消息的响应机制
Mfc消息的响应机制 Mfc中有很多资源,如图标资源,菜单资源,工具栏资源等等:那么,资源是如何进行消息响应和消息映射的呢? 它们的流程是: 某种资源——对应的ID号——消息映射——响应函数的声明与实 ...
- ajax后台处理返回json值
public ActionForward xsearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, Htt ...
- css Gradients(渐变)
渐变分为4类 1:线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向 2:径向渐变(Radial Gradients)- 由它们的中心定义 3:对角渐变 4:角度渐变 以 ...
- iOS基本控制-UINavigationController 传统的价值观,代理传统价值观,正向传统价值观,反传统的价值观
/* 程序过程: 1.创建一个根视图,一个二级视图 2,根视图NavigationItem.title = Root 二级视图NavigationItem.title = Secon ...
- Android L动画入门
Android L带来了许多新特性,其中就包括了大量的动画效果,你可以在自己的应用中使用.本文中我将详解这些动画和如何在应用中使用.本文中的所有代码可以在github上找到. 波纹和强调 现在安卓支持 ...
- 【c语言】统计一个数二进制中的1的个数
// 统计一个数二进制中的1的个数 #include <stdio.h> int count(int a) { int count = 0; while (a) { count++; a ...