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<math.h>
  4. #define N 1100
  5. int main()
  6. {
  7. int n,a[N],b[N],i,j;
  8. while(scanf("%d",&n),n)
  9. {
  10. for(i=;i<n;i++)
  11. {
  12. scanf("%d",&a[i]);
  13. b[i]=a[i];
  14. }
  15. for(i=;i<n;i++)
  16. {
  17. for(j=;j<i;j++)
  18. {
  19. if(a[j]<a[i]&&b[i]<a[i]+b[j])
  20. b[i]=a[i]+b[j];
  21. }
  22. }
  23. int maxn=;
  24. for(i=;i<n;i++)
  25. {
  26. if(maxn<b[i])
  27. maxn=b[i];
  28. }
  29. printf("%d\n",maxn);
  30. }
  31. return ;
  32. }

动态规划:HDU1087Super Jumping! Jumping! Jumping!(最大上升和)的更多相关文章

  1. HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)

    传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...

  2. 【动态规划】矩形嵌套 (DGA上的动态规划)

    [动态规划]矩形嵌套 时间限制: 1 Sec  内存限制: 128 MB提交: 23  解决: 9[提交][状态][讨论版] 题目描述 有n个矩形,每个矩形可以用a,b来描述,表示长和宽.矩形X(a, ...

  3. 【CF1097E】Egor and an RPG game(动态规划,贪心)

    [CF1097E]Egor and an RPG game(动态规划,贪心) 题面 洛谷 CodeForces 给定一个长度为\(n\)的排列\(a\),定义\(f(n)\)为将一个任意一个长度为\( ...

  4. 树型动态规划(树形dp)

    树型动态规划就是在“树”的数据结构上的动态规划,树型动态规划是建立在树上的,所以有二个方向: 1.根—>叶:这种题目基本上碰不到 2.叶->根:根的子节点传递有用的信息给根,完后根得出最优 ...

  5. 算法-动态规划 Dynamic Programming--从菜鸟到老鸟

    算法-动态规划 Dynamic Programming--从菜鸟到老鸟      版权声明:本文为博主原创文章,转载请标明出处. https://blog.csdn.net/u013309870/ar ...

  6. Luogu 2540 斗地主增强版(搜索,动态规划)

    Luogu 2540 斗地主增强版(搜索,动态规划) Description 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来进行的扑克牌游 ...

  7. Luogu 2668 NOIP 2015 斗地主(搜索,动态规划)

    Luogu 2668 NOIP 2015 斗地主(搜索,动态规划) Description 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来 ...

  8. 动态规划入门——数字三角形(Java)

    动态规划的概念对于新手来说枯燥难懂,就算看懂了,做题的时候依旧抓耳挠腮的毫无头绪,这些比较难理解的算法,还是需要根据例子来一步步学习和理解,从而熟练掌握,下面,咱们就通过一个简单的小例子来学习动态规划 ...

  9. Luogu 1063 能量项链(动态规划)

    Luogu 1063 能量项链(动态规划) Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某 ...

随机推荐

  1. 《Python基础教程》 读书笔记 第五章(上)条件语句

    5.1 print和import的更多信息 5.1.1使用逗号输出 打印多个表达式也是可行的,只要将它们用逗号隔开就好: >>>print'age:',42 age: 42 要同时输 ...

  2. mongodb多条件查询总结

    根据两字段乘积过滤查询分页数据 db.cron.aggregate([{$project:{_id:,AppID:,result:{$add:["$endlottery",&quo ...

  3. XCode调试器LLDB

    与调试器共舞 - LLDB 的华尔兹 你是否曾经苦恼于理解你的代码,而去尝试打印一个变量的值? NSLog(@"%@", whatIsInsideThisThing); 或者跳过一 ...

  4. 第16周翻译:SQL Server中的事务日志管理,级别3:事务日志、备份和恢复

    源自: http://www.sqlservercentral.com/articles/Stairway+Series/73779/ 作者: Tony Davis, 2011/09/07 翻译:刘琼 ...

  5. qt5.8+vs2015使用Qt5WebEngine搭建环境

    转载请注明出处:http://www.cnblogs.com/dachen408/p/7575094.html 1.项目属性,C/C++,所有选项,附加包含目录新增. $(QTDIR)\include ...

  6. MongoDB最简单的入门教程之一 环境搭建

    MongoDB是近年来非常流行的一个介于关系数据库和非关系数据库之间的解决方案,特别广泛地应用于国内很多互联网公司,是非关系数据库当中功能最丰富,最像关系数据库的. MongoDB支持的数据结构非常松 ...

  7. HashMap Hashtable TreeMap LinkedHashMap 分析

    首先对hash的了解:就是关键字,和数据建立关系的映射. hash常用算法:假设我们中的字符有相应的内部编码,当然在实际过程中,我们不可能将所有的编码当做hash值. 平方取中法,将所得的内部编码平方 ...

  8. Linux之 if命令——简单的shell文件

    如何写一个shell文件,写一个小脚本 1.新建一个脚本文件:vi demo.sh 2.追加执行权限: chmod u+x demo.sh 3.执行脚本:./demo.sh 4.什么是脚本?把一堆命令 ...

  9. Animate.css_css3动画库介绍

    插件描述:Animate.css内置了很多典型的css3动画,兼容性好使用方便. Animate.css是一个有趣的,跨浏览器的css3动画库.很值得我们在项目中引用. 用法 1.首先引入animat ...

  10. Open Cascade:使用鼠标画线

    Open Cascade:使用鼠标画线 在View类文件中创建以下代码: 1.创建鼠标消息: afx_msg void OnLButtonDown(UINT nFlags, CPoint point) ...