题干:

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,5,2),那么(1,2)也算他的递增子序列。 

  我刚开始做了一遍,忽略了不用连续这个问题,结果发现好简单,提交就是不对,应当注意这里。

  这个还是得用动态规划去做,最后的最优结果是由上一步的结果加上上一次的决策。n个数,由n-1个数的结果加上第n个数。n-1个数由n-2个数的结果。。。。。

  推倒最后,前两个数的的结果就很容易求了.以数列(3,2,4,2,3,6)为例。原博客

  

下标i 0 1 2 3 4 5
a[i] 3 2 4 2 3 6
sum[i] 3 2 7 2 5 13
ans 0 3 7 7 5 13

  

AC代码:

//dp需要赋初值!
#include<bits/stdc++.h>using namespace std;
int n;
int a[1000 + 5];
int dp[1000 + 5];
int main()
{while(~scanf("%d",&n)) {if(n == 0) break;memset(dp,0,sizeof(dp));for(int i = 1; i<=n; i++) scanf("%d",&a[i]);for(int i = 1; i<=n; i++) dp[i] = a[i];for(int i = 1; i<=n; i++) {for(int j = 1; j<i; j++) {if(a[i] > a[j] )dp[i] = max(dp[j] + a[i],dp[i] );}}printf("%d\n",*max_element(dp+1,dp+n+1));}return 0 ;
}

【HDU - 1087】Super Jumping! Jumping! Jumping! (最大上升子序列类问题,dp)相关推荐

  1. hdu 1087 Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  2. hdu 1087 Super Jumping! Jumping! Jumping! 动态规划

    Super Jumping! Jumping! Jumping! Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K ...

  3. DP专题训练之HDU 1087 Super Jumping!

    Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...

  4. hdu 1087 Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  5. HDU 1087 Super Jumping! Jumping! Jumping!【最大递增子段和】

    Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...

  6. 最长上升子序列模板 hdu 1087 Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  7. hdu - 1087 - Super Jumping! Jumping! Jumping!

    题意:求最大升序和. 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 -->>设d[i]表示以第i个数为终点的最大升序和,然后从第1 ...

  8. HDU 1087 [Super Jumping! Jumping! Jumping!]动态规划

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意:有N个格子,每个格子有数值.从原点开始跳,可以跳到任何一个位置:在某一个位置,只能跳到 ...

  9. HDU 1087 Super Jumping! Jumping! Jumping! (最长上升子序列的变形,子序列值最大)

    题意 wsw获得了与小姐姐约会的机会,同时也不用担心wls会发现了,可是如何选择和哪些小姐姐约会呢?wsw希望自己可以循序渐进,同时希望挑战自己的极限,我们假定每个小姐姐有一个"攻略难度值& ...

  10. Super Jumping! Jumping! Jumping! HDU - 1087

    Super Jumping! Jumping! Jumping! HDU - 1087 题意: 给定一条长度为n的序列,其中一定存在一条元素和最大的严格上升子序列,求这条序列的元素和. 题解: 最长上 ...

最新文章

  1. 南京人工智能高等研究院孔慧:多向技术驱动,让企业具备长久竞争力
  2. Oracle数据库实用脚本
  3. Dubbo 在 K8s 下的思考
  4. 极光推送 api ios参数问题
  5. Taro+react开发(80):状态改变的构造函数
  6. InfoQ观点:Java EE的未来
  7. Linux 安装 MySQL 数据库
  8. 假期的游戏陪玩市场,有人挣钱有人被骗
  9. 负载均衡集群介绍LVS介绍LVS调度算法LVS NAT模式搭建
  10. 猴子爬山编程java_Java趣味编程100例
  11. Django == Model基础
  12. 流文件 服务器无响应,文件服务器配置程序未响应
  13. VS2010 SP1安装卡在VS10Sp1-KB983509处的解决(转)
  14. 【转】对前端质量保障的思考 - Barret Lee
  15. cwtvc工况_C-WTVC循环数据.xls
  16. 哈雷haley教你如何用你的手机测试你的移动端项目
  17. mac夜神模拟器与mac数据共享设置
  18. 十问旷视印奇、唐文斌:AI企业都在经历「死亡之谷」
  19. linux查看固态硬盘寿命,CentOS下查看 ssd 寿命
  20. QGIS基础教程 (入门级)——下载安装、新建工程、加载数据

热门文章

  1. [Leetcode][第785题][JAVA][判断二分图][BFS][DFS]
  2. 1143. Lowest Common Ancestor
  3. win10计算机启动一分钟重启,Win10开机提示电脑将在一分钟后自动重启怎么办?...
  4. eclipse maven项目 class类部署不到tomcat下_Servlet tomcat部署
  5. c#日期转换周几_Java时间与日期
  6. 保存到数据库乱码mysql_Linux下MySQL保存进去数据为乱码的解决办法
  7. java解析dxf文件_浅析JVM方法解析、创建和链接
  8. webdriver 爬虫 java_java爬虫通过selenium+WebDriver遍历页面链接报错
  9. asterisk账号和拨号方案mysql存储(静态)
  10. java中Class对象详解