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 ...
随机推荐
- IIS设置aspx映射html
1.打开iis6.0的Internet 信息服务(IIS)管理器,如下图 2.点击网站——选中自己的站点点击右键——属性 3.选中主目录选项卡,点击配置按钮,如下图: 4.在弹出的窗口中点击添加: 5 ...
- C语言中文件定位函数总结
C语言中文件定位函数主要是:fseek, ftell, fsetpos, fgetpos. 先来讲前两个函数,这是最基本的定位函数: fseek函数:能把文件指针移动到文件任何位置,其原型是:int ...
- <Android Framework 之路>Android5.1 Camera Framework(一)
Android5.0 Camera Framework 简介 CameraService启动 CameraService是在MediaServer启动过程中进行的 main_mediaserver.c ...
- Sentry: Python 实时日志平台
Links https://docs.getsentry.com/on-premise/quickstart/ https://docs.getsentry.com/on-premise/server ...
- EXCEL 表格保护破解
'Alt + F11 进入vb编辑器,插入代码,然后在宏查看器里执行,大概等1-2分钟,完成. Public Sub AllInternalPasswords() ' Breaks workshe ...
- POJ 1185 炮兵阵地 (状压dp)(棋盘dp)
这题和poj 3254很像,但是更复杂了一些 都属于棋盘里放东西,然后又各种各样的限制,然后求方案或者最大值 (1)上一道题距离要大于1,这道题是大于2.所以判断的时候变成 !(x & (x ...
- openvswith Frequently Asked Questions
Open vSwitch <http://openvswitch.org> 参考地址:http://git.openvswitch.org/cgi-bin/gitweb.cgi?p=ope ...
- unity 支持圆形、切倒角和虚化UGUI Shader
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt ...
- jquery中的jsonp跨域调用
jquery jsonp跨域调用接口
- 华硕VX50V开机老是进入bios
问题:华硕VX50V开机老是进入bios 如图: 解决办法: 1.将 Boot 中的--->> Lunch CSM ---->>设置为 -->> ena ...