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
解题思路:题意就是求单调递增子序列的最大和,数据比较小,改一下LIS的O(n^2)算法模板即可。
AC代码(15ms):
 #include<bits/stdc++.h>
using namespace std;
int n,maxsum,s[],dp[];
int main(){
while(~scanf("%d",&n)&&n){
memset(dp,,sizeof(dp));maxsum=;
for(int i=;i<n;++i)scanf("%d",&s[i]),dp[i]=s[i];//每个s[i]都是一个递增子序列的开始
for(int i=;i<n;++i){
for(int j=;j<i;++j)
if(s[j]<s[i])dp[i]=max(dp[i],dp[j]+s[i]);//构成递增子序列,更新其和值
maxsum=max(maxsum,dp[i]);//更新最大值
}
printf("%d\n",maxsum);
}
return ;
}

题解报告:hdu 1087 Super Jumping! Jumping! Jumping!的更多相关文章

  1. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...

  2. HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...

  3. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...

  4. HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *

    Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64 ...

  5. hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...

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

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

  8. hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  9. HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

随机推荐

  1. 磁盘显示为GPT(保护分区)

    问题描述:PE进入系统,在计算机管理里面磁盘显示为GPT(保护分区).此时硬盘是不能重新分区或者格式化的. 解决思路:低版本的WIndows(PE)是不支持GPT分区的,我们需要使用系统自带的Disk ...

  2. ln 软连接 & 硬连接

    创建软连接的方式 #ln -s soure /file object 创建软连接是连接文件本身,可以跨分区建立软连接,不会应为不同分区而出现不能使用的问题. 在创建软连接的文件中,修改一处文件另一处同 ...

  3. SDUTOJ 2475 Power Strings

    <pre class="cpp" name="code">#include<iostream> #include<stdio.h& ...

  4. Python筛选法(算出十亿之内所有的质数之和)

    其实别人写的挺好的了....直接上链接吧http://blog.csdn.net/power721/article/details/8216619

  5. swagger 如何在UI界面加入Authentication token值

    接口 2.access_token 值: 3  输入值:bearer+空格+值

  6. 在 Ubuntu 开启 GO 程序编译之旅

    本文将使用 putty 连接到一台阿里云 Ubuntu 16.04 服务器,在其上安装 go 语言的编译环境,旨在呈现从安装到"你好,世界!"涉及的方方面面,希望完成这个过程无须觅 ...

  7. 识别IE11浏览器

    现在俺们做的系统十分高大上,用IE的话非要上IE11或以上版本. 咋检测呢?检测到用户用IE.且IE低于IE11的话就提示他升级浏览器呢?可以酱紫: var _IE = (function (d, w ...

  8. 漫谈Deep PCA与PCANet

    又到了无聊的写博客的时间了,因为电脑在跑程序.眼下无事可做.我认为把昨天我看的一些论文方面的知识拿出来和大家分享一下. 美其名曰我是在研究"深度学习".只是因为本人是穷屌丝一个,买 ...

  9. 什么是PMU(PMIC)【转】

    本文转载自:http://blog.csdn.net/zhenwenxian/article/details/7614537 什么是PMU(PMIC) PMU(power management uni ...

  10. HDU3038 How Many Answers Are Wrong —— 带权并查集

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3038 How Many Answers Are Wrong Time Limit: 200 ...