HDU 1087 Super Jumping! Jumping! Jumping!【DP】
解题思路:题目的大意是给出一列数,求这列数里面最长递增数列的和
dp[i]表示到达地点i的最大值,那么是如何达到i的呢,则我们可以考虑没有限制条件时候的跳跃,即可以从第1,2,3,---,i-1个地点跳跃到i,
而题目限定了,跳到的那个点的数要比开始跳的那个点的数大
所以,状态转移方程式为
for(i=1;i<=n;i++)
for(j=0;j<i;j++)
if(a[j]>a[i])
dp[i]=max(dp[j]+a[i],dp[i]);//找出到达地点i的最大值
反思:本来想的是如果给了n个点的话,那么我再加一个点,则n+1点变成终点,则不管怎么跳,都会到达终点,所以dp[n+1]即为所求
不过没有写出来,最后还是每次求出一个dp的值来比较求到了最大值。
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23935 Accepted Submission(s): 10519
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.#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[1005],a[1005];
int main()
{
int n,i,j,maxx;
while(scanf("%d",&n)!=EOF&&n)
{
memset(dp,0,sizeof(dp));
maxx=dp[0];
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
for(j=0;j<i;j++)
{
dp[i]=max((dp[j]+a[i])*(a[i]>a[j]),dp[i]);
if(dp[i]>maxx)
maxx=dp[i];
}
}
printf("%d\n",maxx);
}
}
HDU 1087 Super Jumping! Jumping! Jumping!【DP】的更多相关文章
- HDU 1024 Max Sum Plus Plus【DP】
Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDOJ_1087_Super Jumping! Jumping! Jumping! 【DP】
HDOJ_1087_Super Jumping! Jumping! Jumping! [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 【dp】动归总结
原标题:[DP专辑]ACM动态规划总结 转载自 http://blog.csdn.net/cc_again?viewmode=list http://blog.csdn.net/cc_again/ar ...
- Kattis - honey【DP】
Kattis - honey[DP] 题意 有一只蜜蜂,在它的蜂房当中,蜂房是正六边形的,然后它要出去,但是它只能走N步,第N步的时候要回到起点,给出N, 求方案总数 思路 用DP 因为N == 14 ...
- HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】
HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...
- HDOJ 1501 Zipper 【DP】【DFS+剪枝】
HDOJ 1501 Zipper [DP][DFS+剪枝] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDOJ 1257 最少拦截系统 【DP】
HDOJ 1257 最少拦截系统 [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDOJ 1159 Common Subsequence【DP】
HDOJ 1159 Common Subsequence[DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- POJ_2533 Longest Ordered Subsequence【DP】【最长上升子序列】
POJ_2533 Longest Ordered Subsequence[DP][最长递增子序列] Longest Ordered Subsequence Time Limit: 2000MS Mem ...
随机推荐
- 鲜为人知的 Windows 技能
IE/Edge 竟然可以转换图片格式 SVG 转 PNG.SVG 转 BMP 在图片上点击右键,选择"图片另存为" Windows/Office 屏幕录制 office 竟然带有屏 ...
- oc与swift比较
swift试是用语言层面的雕虫小技和oc的机制大道进行pk. 从整体上来说,oc是一个更加优秀的语言.
- css3新增的属性有哪些
徐先森讲web CSS3新增的属性有哪些: CSS 用于控制网页的样式和布局. CSS3 是最新的 CSS 标准. CSS3新增了很多的属性,下面一起来分析一下新增的一些属性: 1.CSS3边框: b ...
- C# 基础复习 四 ADO
调用存储过程,并接收多个表的查询结果 一个表用一个DataTable,DataSet可以存储多个DataTable DataSet需要SqlDataAdapter来填充数据 SqlConnection ...
- node——服务器根据不同请求作出不同响应+响应html文件等文件
在浏览器中,不同的请求应该作出不同的响应 我们可以从请求req中的url获得请求的内容 然后我们就可以通过判断请求的url来做响应 代码如下: //根据用户的不同请求,服务器做出不同的响应 // // ...
- Python笔记25-----------创建二维列表【浅copy】和转置
一.创建二维列表 1.二维列表创建第二维的时候,如果采用*2这种方式,这是一种浅复制的方式,同时引用到同一个list,如上图的C. 这种形式,不方便修改C[ i ][ j ]的数据,如果改C[ 0 ] ...
- GRUB 引导流程
GRUB(bootloader)引导流程: GRUB,GRand Unified Bootlader ,是一个来自GUN项目的多操作系统启动程序.GRUB是多启动规范的实现,它允许用户可以在计算机内 ...
- linux--rbtree 解惑 insert
rbtree.txt 中insert 操作,为何用2级指针?? 2级指针用的还是不熟.心虚. Inserting data in the tree involves first searching f ...
- Lapack下载安装
安装 1.下载压缩文件 wget http://www.netlib.org/lapack/lapack-3.8.0.tar.gz 2.解压缩 tar -zxvf lapack-3.8.0.tar.g ...
- JavaScript和CSS实用工具、库与资源
JavaScript和CSS实用工具.库与资源 JavaScript 库 Particles.js - 一个用于在网页上创建漂亮的浮动粒子的 JS 库: Three.js - 用于在网页上创建 3 ...