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. Django项目:CRM(客户关系管理系统)--50--41PerfectCRM实现全局账号密码修改

    # gbacc_urls.py # ————————38PerfectCRM实现全局账号登录注销———————— from django.conf.urls import url from gbacc ...

  2. 工控安全入门(二)—— S7comm协议

    在上一次的文章中我们介绍了施耐德公司的协议modbus,这次我们把目标转向私有协议,来看看另一家巨头西门子的S7comm.首先要说明,这篇文章中的内容有笔者自己的探索,有大佬们的成果,但由于S7com ...

  3. CF573E (平衡树)

    CF573E 题意概要 给出一个长度为\(n\)的数列,从中选出一个子序列\(b[1...m]\)(可以为空) 使得\[ \sum_{i=1}^m{b_i*i}\]最大,输出这个最大值. 其中\(n\ ...

  4. QT_获取运行进程所在目录路径_2

    QString getProcessFullPath(const quint64 &processId) { #ifdef Q_OS_WIN // access process path WC ...

  5. 清除SQL数据库文本字段中的回车、换行符的方法

    清除SQL数据库中文本字段的回车.换行符的方法 清除回车符: update tableName set columnName = rtrim(ltrim(replace(columnName ,cha ...

  6. VMware安装Centos后无法上网

    参考于: http://www.xpxt.net/xtjc/win8/04194953.html

  7. StringBuilder / StringBuffer类

    StringBuilder类 和 StringBuffer 类的由来? 在Java中使用String 类可以描述所有的字符串数据,但是String类的对象一旦创建,则该对象的字符序列 就不可更改,当需 ...

  8. Java 1.8 Stream 用例测试

    package stream; import model.Student; import org.junit.jupiter.api.Test; import java.util.*; import ...

  9. Codeforces Round #395 (Div. 2) A. Taymyr is calling you【数论/最小公倍数】

    A. Taymyr is calling you time limit per test 1 second memory limit per test 256 megabytes input stan ...

  10. 洛谷 P1420 最长连号【最长合法子序列/断则归一】

    题目描述 输入n个正整数,(1<=n<=10000),要求输出最长的连号的长度.(连号指从小到大连续自然数) 输入输出格式 输入格式: 第一行,一个数n; 第二行,n个正整数,之间用空格隔 ...