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

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
 
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. using namespace std;
  5. int dp[1005],a[1005];
  6. int main()
  7. {
  8. int n,i,j,maxx;
  9. while(scanf("%d",&n)!=EOF&&n)
  10. {
  11. memset(dp,0,sizeof(dp));
  12. maxx=dp[0];
  13. for(i=1;i<=n;i++)
  14. scanf("%d",&a[i]);
  15. for(i=1;i<=n;i++)
  16. {
  17. for(j=0;j<i;j++)
  18. {
  19. dp[i]=max((dp[j]+a[i])*(a[i]>a[j]),dp[i]);
  20. if(dp[i]>maxx)
  21. maxx=dp[i];
  22. }
  23. }
  24. printf("%d\n",maxx);
  25. }
  26. }

  

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. layui表格的新增和编辑功能前端代码

    html页面的代码(注意:引入layui相关的css): <div class="layui-form-item"> <label class="lay ...

  2. vue中通过js控制页面样式方法

    在使用vue.js框架的时候,有时候会希望在页面渲染完成之后,再执行函数方法来处理初始化相关的操作,如果只处理页面位置.宽或者高时,必须要在页面完全渲染之后才可以,页面没有加载完成之前,获取到的宽高不 ...

  3. I'm studying Bootstrap! loading...

    最近在学习bootstrap框架. Bootstrap框架是目前前端最受欢迎的框架,出于Twitter公司!搞前端你说你不会Bootstrap都不好意思见人呢. Bootstrap是基于Html Cs ...

  4. Unity Android发布“Bundle Identifier has not been set up correctly”

    原文:http://answers.unity3d.com/questions/162141/android-bundle-identifier-has-not-been-setup.html

  5. Unity 退出游戏 方法

    Application.Quit(); 嗯,没错,这篇就这么短.

  6. Unity 组件的增、查、禁、删 代码书写

    using UnityEngine; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization ...

  7. java 公开内部类无法实例化 no enclosing instance 解决办法

    因为B类不是A类的静态内部类,所以B累也只能像A类的成员一样通过new A()的实例访问,new(new A()).B(),这显然不是我们想要的方式,于是需要在B类的前边加上static,变成下边这样 ...

  8. 池(Pool)

    #1 就是一个资源的集合,用的时候按照你的需要去取,用完了给人家放回去 #2 学编程的时候,老师给我们的解释过池的意思,大概是: 如果你喝水,你可以拿杯子去水龙头接.如果很多人喝水,那就只能排队去接. ...

  9. IOS - IOS之同步请求、异步请求、GET请求、POST请求(转载)

    转载:http://www.open-open.com/lib/view/open1355055986679.html 1.同步请求可以从因特网请求数据,一旦发送同步请求,程序将停止用户交互,直至服务 ...

  10. BZOJ 4026 dC Loves Number Theory (主席树+数论+欧拉函数)

    题目大意:给你一个序列,求出指定区间的(l<=i<=r) mod 1000777 的值 还复习了欧拉函数以及线性筛逆元 考虑欧拉函数的的性质,(l<=i<=r),等价于 (p[ ...