解题思路:题目的大意是给出一列数,求这列数里面最长递增数列的和

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

Problem Description
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.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.
 
Input
Input contains multiple test cases. Each test case is described in a line as follow: 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.
 
Output
For each case, print the maximum according to rules, and one line one case.
 
Sample Input
3 1 3 2 4 1 2 3 4 4 3 3 2 1 0
 
Sample Output
4 10 3
 
#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】的更多相关文章

  1. 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 ...

  2. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...

  3. HDOJ_1087_Super Jumping! Jumping! Jumping! 【DP】

    HDOJ_1087_Super Jumping! Jumping! Jumping! [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...

  4. 【dp】动归总结

    原标题:[DP专辑]ACM动态规划总结 转载自 http://blog.csdn.net/cc_again?viewmode=list http://blog.csdn.net/cc_again/ar ...

  5. Kattis - honey【DP】

    Kattis - honey[DP] 题意 有一只蜜蜂,在它的蜂房当中,蜂房是正六边形的,然后它要出去,但是它只能走N步,第N步的时候要回到起点,给出N, 求方案总数 思路 用DP 因为N == 14 ...

  6. HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】

    HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...

  7. HDOJ 1501 Zipper 【DP】【DFS+剪枝】

    HDOJ 1501 Zipper [DP][DFS+剪枝] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...

  8. HDOJ 1257 最少拦截系统 【DP】

    HDOJ 1257 最少拦截系统 [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...

  9. HDOJ 1159 Common Subsequence【DP】

    HDOJ 1159 Common Subsequence[DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...

  10. POJ_2533 Longest Ordered Subsequence【DP】【最长上升子序列】

    POJ_2533 Longest Ordered Subsequence[DP][最长递增子序列] Longest Ordered Subsequence Time Limit: 2000MS Mem ...

随机推荐

  1. TCP基本概念

    TCP协议是一个复杂的.可靠的字节流协议.不通用UDP协议. TCP提供客户与服务器之间的连接.TCP客户先与给定的服务器建立一个连接,再跨该连接与服务器交换数据,最后终止这个连接. TCP提供了可靠 ...

  2. Django-admin源码解析

    启动 <1>启动django,运行manage.py文件,进行当前项目的环境配置 <2>按照INSTALLED_APPS中的顺序加载APP,首先加载admin 注册 <1 ...

  3. 第一章 关于python

    Python简介 Python是什么?   python的创始人为吉多·范罗苏姆(Guido van Rossum).  “Python is a great object-oriented, int ...

  4. day21 模块

    目录 模块 import 与 from...import 循环导入问题 解决方案一 解决方案二 Python文件的两种用途 从普通的面条型代码,到函数型代码,其实是在做什么? 封装代码,一个函数差不多 ...

  5. Python socket通信之FTP

    Python中利用socket进行server端和client端通信是网络编程的基础,是最简单的传输范例. (懂网络的请自动跳过这一部分) 首先,要想通信,必须建立连接,建立连接的过程,需要clien ...

  6. oracle 控制语句

    PL输出语句 set serverout on; -- 开启PL的输出语句功能declare n number:=1; -- 声明一个number型的变量n,并赋值为1 v varchar2(20): ...

  7. Eclipse配置Maven私服

    Eclipse配置Maven私服 前言: 搭建Maven私有仓库的主要目的,是为了在团队多人开发时,只要内网的私有仓库有下载过依赖的jar包,就直接从私有仓库获取,不再通过外网的中央仓库.如果私服上面 ...

  8. Android中的单位

    Android中的单位 1.px 像素(pixels) VGA 480*640像素 (Video Graphics Array) QVGA 240*320像素 (Quarter VGA) HVGA 3 ...

  9. STL 之 iterator traits 备忘

    //5种迭代器.为了激活重载机制,定义的5个类型.每种迭代器就是一个类型. struct input_iterator_tag{}; struct output_iterator_tag{}; str ...

  10. HDOJ 5299 Circles Game 圆嵌套+树上SG

    将全部的圆化成树,然后就能够转化成树上的删边博弈问题.... Circles Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: ...