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

#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<cstdio>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) ((a)>0?(a):-(a))
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
int dp[],value[];    //dp[i]指以dp[i]结尾的子序列的最大和 int main()
{
int n;
while((scanf("%d",&n)!=EOF),n)
{
memset(dp,,sizeof(dp));
     //求出每个dp[i]
for(int i=;i<n;i++)
{
scanf("%d",&value[i]);
int maxn=-INF;
for(int j=;j<i;j++){
if((dp[j]>maxn)&&(value[j]<value[i])){
maxn=dp[j];
}
}
dp[i]=max(value[i],value[i]+maxn);
} int maxn=-INF;
for(int i=;i<n;i++)
{
if(maxn<dp[i])maxn=dp[i];
}
cout<<maxn<<endl; }
return ;
}

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. Snowflake Snow Snowflakes(哈希表的应用)

    Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 27312   Accep ...

  2. HTML5的input color系统颜色选择器

    前两天,我写了一篇<推荐两款jQuery色盘选择器>介绍,那是使用JavaScript实现的色盘,今天我给大家介绍HTML5的色盘选择器.HTML5有一个input类型为color,即颜色 ...

  3. loj 1377 (bfs)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1377 思路:这道题只要处理好遇到"*"这种情况就可以搞定了.我们可 ...

  4. UVA136 求第1500个丑数

    枚举大范围数据..暴力检查题目条件 #include <iostream> #include <cstdio> #include <vector> #include ...

  5. 【MongoDB --番外】错误集合

    1.在第一次安装成功之后,就瞬间发现了如下问题 mongodb无法启动,由于目标计算机积极拒绝,无法连接 解决方法: 这不是mongodb无法启动,是你还没有启动mongodb就来连接使用它了,肯定是 ...

  6. BurpSuite的使用总结

    BurpSuite BurpSuite 是一款使用Java编写的,用于Web安全审计与扫描套件.它集成了诸多实用的小工具以完成http请求的转发/修改/扫描等,同时这些小工具之间还可以 互相协作,在B ...

  7. web_custom_request应用示例

    web_custom_request应用示例 LoadRunner提供的web_custom_request函数可以用于实现参数的动态生成.在LoadRunner中,web_reg_save_para ...

  8. AOP动态代理解析4-jdk代理的实现

    JDKProxy的使用关键是创建自定义的InvocationHandler,而InvocationHandler中包含了需要覆盖的函数getProxy,而当前的方法正是完成了这个操作.在此确认一下JD ...

  9. PHP 垃圾回收机制

    PHP垃圾回收说到底是对变量及其所关联内存对象的操作, 所以在讨论PHP的垃圾回收机制之前,先简要介绍PHP中变量及其内存对象的内部表示(其C源代码中的表示). PHP官方文档中将PHP中的变量划分为 ...

  10. java发送短信--httpclient方式

    最近头让我写个发送短信的java程序检测BI系统,检查数据库是否有异常发送,有则发送短信到头的手机里.这里我直说httpclient方式的get请求方式,并且已经有方式的短信的接口了,所以只要再加上参 ...