Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

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

题意:跳数字游戏,下一个数字必须比当前数字大,每一次都可以 获取当前数字的值

题解:dp求上升序列的和

Select Code

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const int maxn = 1050; int main()
{
int dp[maxn],s[maxn],n,i,j,Max,mm;
while(scanf("%d",&n)!=EOF&&n)
{
for(i=0;i<n;i++)
scanf("%d",&s[i]);
dp[0] = s[0];
Max = s[0];
for(i=1;i<n;i++)
{
mm = 0;
for(j=0;j<i;j++)
{
if(s[i]>s[j]&&mm<dp[j])
mm = dp[j];
}
dp[i] = mm + s[i];
Max = max(Max,dp[i]);
}
printf("%d\n",Max);
}
return 0;
}

HDU_1087-Super Jumping! Jumping! Jumping!的更多相关文章

  1. HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)

    传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...

  2. E - Super Jumping! Jumping! Jumping!

    /* Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popula ...

  3. Super Jumping! Jumping! Jumping!

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

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

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

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

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

  6. Super Jumping! Jumping! Jumping!——E

    E. Super Jumping! Jumping! Jumping! Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO forma ...

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

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

  8. HDU 1087 Super Jumping! Jumping! Jumping

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

  9. HDU 1087 Super Jumping! Jumping! Jumping! (DP)

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

  10. HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)

    Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...

随机推荐

  1. 移动端 Iphone拍照变横问题的解决

    在移动端的页面需要做用户拍照上传的功能时会有用,苹果即使竖着拍照,上传到网页后它也会变成横的,好像IOS得一个BUG,安卓就没有这个问题. 要解决这个问题需要引入exif.js这个库,网上随便搜一下就 ...

  2. php5 常量

    <?php define("GREETING", "Welcome to w3cschool.cn!", true); echo greeting; ?& ...

  3. jeecms 强大的采集功能优化 转载 https://blog.csdn.net/jeff06143132/article/details/7099003

    ========================================================= 没办法附件上传不了,AcquisitionSvcImpl.java类: //---- ...

  4. birt运行环境

    1.下载 http://pan.baidu.com/s/1nvhz5wt 2.解压birt-runtime-4.6.0-20160607.zip 将WebViewerExample更名为birt,复制 ...

  5. CentOS 7 SVN搭建 (YUM安装)

    1.检查已安装版本 rpm -qa subversion卸载旧版本SVNyum remove subversion2.安装SVNyum install subversion 3.验证安装svnserv ...

  6. CentOS 7安装与配置Tomcat8

    1.下载安装包并上传服务器 2.解压 tar -zxvf apache-tomcat-8.5.16.tar.gz -C /opt/java 3.启动 cd /opt/java/apache-tomca ...

  7. javascript之键盘事件的方法

    键盘事件包含onkeydown.onkeypress和onkeyup这三个事件 事件初始化 function keyDown(){} document.onkeydown = keyDown; //论 ...

  8. JSON和JSONP,原来ajax引用这个来实现跨域访问的

    由于Sencha Touch 2这种开发模式的特性,基本决定了它原生的数据交互行为几乎只能通过AJAX来实现. 当然了,通过调用强大的PhoneGap插件然后打包,你可以实现100%的Socket通讯 ...

  9. ubuntu上用源码进行一键安装mysql

      首先卸载原有的mysql: 首先查看自己的mysql有哪些依赖 #dpkg --list|grep mysql 先卸载 #sudo apt-get remove mysql-common #sud ...

  10. 模拟退火解TSP问题MATLAB代码

    分别把前四个函数存成m文件,再运行最后一个. swap.m function [ newpath , position ] = swap( oldpath , number ) % 对 oldpath ...