hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087
----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋:http://user.qzone.qq.com/593830943/main
----------------------------------------------------------------------------------------------------------------------------------------------------------
Super Jumping! Jumping! Jumping!

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.
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
4
10
3
代码例如以下:
#include <cstdio>
#define N 1017
int main()
{
int n;
int a[N], dp[N];
int i, j;
int max;
while(~scanf("%d",&n) && n)
{
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
}
dp[0] = max = a[0];
for(i = 1; i < n; i++)
{
dp[i] = a[i];
for(j = 0; j < i; j++)
{
if(a[i] > a[j])
{
if(dp[j]+a[i] > dp[i])
{
dp[i] = dp[j]+a[i];
}
}
}
if(dp[i] > max)
max = dp[i];
}
printf("%d\n",max);
}
return 0;
}
hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)的更多相关文章
- hdu 4352 XHXJ's LIS 数位DP+最长上升子序列
题目描述 #define xhxj (Xin Hang senior sister(学姐))If you do not know xhxj, then carefully reading the en ...
- hdu 1503:Advanced Fruits(动态规划 DP & 最长公共子序列(LCS)问题升级版)
Advanced Fruits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- hdu 1025 dp 最长上升子序列
//Accepted 4372 KB 140 ms //dp 最长上升子序列 nlogn #include <cstdio> #include <cstring> #inclu ...
- DP——最长上升子序列(LIS)
DP——最长上升子序列(LIS) 基本定义: 一个序列中最长的单调递增的子序列,字符子序列指的是字符串中不一定连续但先后顺序一致的n个字符,即可以去掉字符串中的部分字符,但不可改变其前后顺序. LIS ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDU 1087 Super Jumping! Jumping! Jumping! --- DP入门之最大递增子序列
DP基础题 DP[i]表示以a[i]结尾所能得到的最大值 但是a[n-1]不一定是整个序列能得到的最大值 #include <bits/stdc++.h> using namespace ...
- HDU 1087 Super Jumping! Jumping! Jumping! --- DP入门之最大上升子序列
题目链接 DP基础题 求的是上升子序列的最大和 而不是最长上升子序列LIS DP[i]表示以a[i]结尾所能得到的最大值 但是a[n-1]不一定是整个序列能得到的最大值 #include <bi ...
- HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)
传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...
- HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
随机推荐
- [Angular2 Router] Auxiliary Routes bit by bit
Article Github Auxiliary Routes is is little bit hard to understand. Here is demo, link You can see ...
- Topological Spaces(拓扑空间)
拓扑空间的定义有多种形式,通过 open sets(开集)的形式定义是最为常见的拓扑空间定义形式. 1. 通过开集(open sets)定义 拓扑空间由一个有序对 (X,τ) 表示,X 表示非空集合, ...
- JAVA 日志库3
Commons Logging和SLF4J都是基于相同的设计,即从一个LogFactory中取得一个命名的Log(Logger)实例,然后使用这个Log(Logger)实例打印debug.in ...
- ANSCII码和BCD码互转
bool AtoBCD(unsigned char* Asc,unsigned char* BCD,int len) { int i; unsigned char ch; //高位 unsigned ...
- [Jade] Use Mixins in Pug
Mixin works as a function. extends layout include mixins/storeForm block content .inner h2 #{title} ...
- ARM 授权费用太贵 科技巨头欲转向开源架构 RISC-V
不久前,特斯拉加入 RISC-V 基金会,并考虑在新款芯片中使用免费的 RISC-V 设计.至此,已有 IBM.NXP.西部数据.英伟达.高通.三星.谷歌.华为等 100 多家科技公司加入 RISC- ...
- 移动web处理input输入框输入银行卡号四位一空格
由于项目上有需求要求输入银行卡号四位一空格的需求,改过好几版发现都有bug,最后优化了一版看起来效果还行,发帖留存. 难点是从中间插入和删除处理光标问题. 首先需要用到获取光标和设置光标的方法. // ...
- LDAP Browser/Editor v2.8.2
https://www.netiq.com/communities/cool-solutions/wp-content/uploads/sites/2/2009/07/Gawor_ldapbrowse ...
- Java算法--串的简单处理
题目例如以下: 串的处理 在实际的开发工作中.对字符串的处理是最常见的编程任务. 本题目即是要求程序对用户输入的串进行处理.详细规则例如以下: 1. 把每个单词的首字母变为大写. 2. 把数字与字母之 ...
- Session or Cookie?是否需要用Tomcat等Web容器的Session
Cookie是HTTP协议标准下的存储用户信息的工具,浏览器把用户信息存放到本地的文本文件中. Session是基于Cookie实现的. 2011年4月,武汉群硕面试的时候(实习生),面试官也问过这个 ...