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. IOS 100 - 1 开工闲聊

    1 前言 现在的行情,作为码农,ios 普遍比c# 的待遇好上不少.感觉就如清洁工人,扫厕所干的再高效和干净,一个月就那么点微薄的收入.当然你可以选择去香港打扫卫生间,那里的行情据说清洁工也破万了.说 ...

  2. [荐]使用jQuery清空file文件域

    file是文本域,我们一般都会使用它来上传文件,在上传文件时我们需要验证,验证完成后,如果存在错误,为了防止将错误信息也上传上去,我们总是希望能够将其清空.但是在IE中,为了安全起见它是不允许我们改变 ...

  3. ZEALER背后的乐视云视频

    ZEALER是我非常喜欢的一个测评网站,经常访问看看手机.电动牙刷及机械键盘的测试视频,非常欣赏王自如的数据化测评理念.敬畏之心,以及不祛痘的视频. 刚好最近对网络视频应用比较感兴趣,觉得ZEALER ...

  4. loj 1379(最短路变形)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27087 思路:题目的意思是求S->T的所有路径中花费总和小于 ...

  5. 汇编学习(四)——算术运算程序

    (一)跳转指令 一.无条件跳转指令(不管标志寄存器,执行到这句直接跳转) 1.段内直接跳转指令 (1)指令格式: JMP SHORT short_label; IP<--IP+DB,即代码直接跳 ...

  6. HDU 5867 Sparse Graph (2016年大连网络赛 I bfs+补图)

    题意:给你n个点m条边形成一个无向图,问你求出给定点在此图的补图上到每个点距离的最小值,每条边距离为1 补图:完全图减去原图 完全图:每两个点都相连的图 其实就是一个有技巧的bfs,我们可以看到虽然点 ...

  7. codeforces 286 div2 B

    思路:质因子累乘的值即为所求#include<iostream> #include<algorithm> #include<stdio.h> #include< ...

  8. flv文件格式解析!!!

    flv头 FLV header 总体上看,FLV包括文件头(File Header)和文件体(File Body)两部分,其中文件体由一系列的Tag组成. Signature: FLV 文件的前3个字 ...

  9. js 事件监听

    addEventListener() 方法 element.addEventListener(event, function, useCapture); 第一个参数是事件的类型 (如 "cl ...

  10. 《DSP using MATLAB》示例Example5.6

    代码: x = [1, 1, 1, 1]; N = 4; X_DFT = dft(x,N); % DFT of x(n) magX_DFT = abs(X_DFT), phaX_DFT = angle ...