Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 33384    Accepted Submission(s): 15093

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

Author

lcy

1、HDU 1087

2、链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087

3、总结:跳数字,求递增子序列使和最大,简单dp

  1. #include<iostream>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<queue>
  5. #include<algorithm>
  6. #include<cstdio>
  7. #define max(a,b) (a>b?a:b)
  8. #define min(a,b) (a<b?a:b)
  9. #define abs(a) ((a)>0?(a):-(a))
  10. using namespace std;
  11. #define LL long long
  12. #define INF 0x3f3f3f3f
  13. int dp[],value[];    //dp[i]指以dp[i]结尾的子序列的最大和
  14.  
  15. int main()
  16. {
  17. int n;
  18. while((scanf("%d",&n)!=EOF),n)
  19. {
  20. memset(dp,,sizeof(dp));
         //求出每个dp[i]
  21. for(int i=;i<n;i++)
  22. {
  23. scanf("%d",&value[i]);
  24. int maxn=-INF;
  25. for(int j=;j<i;j++){
  26. if((dp[j]>maxn)&&(value[j]<value[i])){
  27. maxn=dp[j];
  28. }
  29. }
  30. dp[i]=max(value[i],value[i]+maxn);
  31. }
  32.  
  33. int maxn=-INF;
  34. for(int i=;i<n;i++)
  35. {
  36. if(maxn<dp[i])maxn=dp[i];
  37. }
  38. cout<<maxn<<endl;
  39.  
  40. }
  41. return ;
  42. }

HDU 1087 简单dp,求递增子序列使和最大的更多相关文章

  1. hdu 1087 简单dp

    思路和2391一样的.. <span style="font-size:24px;">#include<stdio.h> #include<strin ...

  2. hdu 2471 简单DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571 简单dp, dp[n][m] +=(  dp[n-1][m],dp[n][m-1],d[i][k ...

  3. HDU 1087 最长不下降子序列 LIS DP

    Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...

  4. HDU-1231 简单dp,连续子序列最大和,水

    1.HDU-1231 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231 3.总结:水 题意:连续子序列最大和 #include<iostre ...

  5. Max Sum (hdu 1003 简单DP水过)

    Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  6. hdu 1257 && hdu 1789(简单DP或贪心)

    第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> ...

  7. hdu 1423 最长公共递增子序列 LCIS

    最长公共上升子序列(LCIS)的O(n^2)算法 预备知识:动态规划的基本思想,LCS,LIS. 问题:字符串a,字符串b,求a和b的LCIS(最长公共上升子序列). 首先我们可以看到,这个问题具有相 ...

  8. HDU 1708 简单dp问题 Fibonacci String

    Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. hdu 1423 最长公共递增子序列

    这题一开始把我给坑了,我还没知道LCIS的算法,然后就慢慢搞吧,幸运的是还真写出来了,只不过麻烦了一点. 我是将该题转换为多条线段相交,然后找出最多多少条不相交,并且其数值死递增的. 代码如下: #i ...

随机推荐

  1. SQLAlchemy Core插入数据,有好几种方法呢

    看是一次插入一条还是多条, 看是数据表名是变量还是常量, 操作还是很灵活的, 主要看哪种顺手顺眼啦. #coding=utf-8 from datetime import datetime from ...

  2. OCJP(1Z0-851) 模拟题分析(七)-->214

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  3. 在 Mac 上安装 sbt

    通过第三方的包安装 注意: 第三方的包可能没有提供最新的版本,请记得将任何问题反馈给这些包相关的维护者. 通过 Macports 安装 $ port install sbt 通过 Homebrew 安 ...

  4. 网站通用登录模块代码 分类: ASP.NET 2014-12-06 10:49 615人阅读 评论(0) 收藏

    1.HTML部分:     <form id="form1" runat="server">     <script src=".. ...

  5. [Skills] 在桌面打开一个BAT文件,CMD窗口不关闭

    每次开机都要取得本机IP,然后远程连接上去,屏幕太小,不好输入,想写个bat,执行就能看到IP,并且停留在cmd窗口上,想来简单,以前搜了好久没找到好的办法,今天找到一个贴子,竟然可以,呵呵!   以 ...

  6. Git提交基本流程

    在无其他分支,大家都向同一分支master分支提交代码的情况下: 1.查看本地对代码的修改情况,即可以被提交的修改记录 git status 其中被修改过的文件标识为modified,删除的文件del ...

  7. 搭建Mantis 缺陷管理系统(转)

    转自 什么是Mantis MantisBT is a free popular web-based bugtracking system (feature list). It is written i ...

  8. indeterminateDrawable

    Android原生控件只有横向进度条一种,而且没法变换样式,比如原生rom的样子很丑是吧,当伟大的产品设计要求更换前背景,甚至纵向,甚至圆弧状的,咋办,比如ok,我们开始吧: 一)变换前背景 先来看看 ...

  9. Linux学习笔记(23) Linux备份

    1. 备份概述 Linux系统需要备份的数据有/root,/home,/var/spool/mail,/etc及日志等其他目录. 安装服务的数据需要备份,如apache需要备份的数据有配置文件.网页主 ...

  10. LoadRunner 事务函数

    status 包括LR_PASS, LR_FAIL,  LR_AUTO,  LR_STOP(这个没用过) lr_set_transaction_instance_status(status); 可以根 ...