Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 49819    Accepted Submission(s): 23076

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

Sample Output

4

10

DP入门题;

#include <stdio.h>
#include <stdlib.h>
#define N 1100 int main()
{
int n;
while(~scanf("%d", &n) && n)
{
int max;
int a[N], dp[N] = {0,};
int i, j;
scanf("%d", &a[0]);
dp[0] = a[0];
for(i=1; i<n; i++)
{
scanf("%d", &a[i]);
dp[i] = a[i];
max = 0;
for(j=0; j<i; j++)
{
if(a[j] < a[i] && dp[j] > max)
{
max = dp[j];
}
}
dp[i] = a[i] + max;
}
max = 0;
for(i=0; i<n; i++)
{
if(dp[i] > max)
{
max = dp[i];
} }
printf("%d\n", max);
}
return 0;
}

HDU-1087-Super Jumping! Jumping! Jumping!(线性DP, 最大上升子列和)的更多相关文章

  1. HDU 1087 Super Jumping! Jumping! Jumping

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

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

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

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

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

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

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

  5. HDU 1069 Monkey and Banana(线性DP)

    Description   A group of researchers are designing an experiment to test the IQ of a monkey. They wi ...

  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! (DP)

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

  10. HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)

    Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...

随机推荐

  1. Android Activity简介和自定义视图

    ------siwuxie95 Activity简单来说就是一个界面(如桌面也是一个Activity),不同按键对Activity的影响不同(如返回键和Home键) 布局在layout下的activi ...

  2. 第一个独特字符位置 · first position unique character

    [抄题]: 给出一个字符串.找到字符串中第一个不重复的字符然后返回它的下标.如果不存在这样的字符,返回 -1. 给出字符串 s = "lintcode",返回 0.给出字符串 s ...

  3. SuSE 网卡配置模板

    heidsoft:/etc/sysconfig/network # cat ifcfg.template ## This is a template for a network interface c ...

  4. FineUI学习

    1.无限级菜单绑定 using (DataTable dt = SqlPagerHelper.GetTableByCondition(DefaultConnection.ConnectionStrin ...

  5. qt学习(一) qt安装

    QT5现在安装已经方便了许多 相比QT4 可以一路点击到底 无需额外的太多的操作. http://download.qt.io/official_releases/ 下载 1 windows下可以选择 ...

  6. 数据挖掘潜规则zz

    声明:本文指的是做数据挖掘这行,不是数据仓库 我干这行有几年了,见了很多人,干了很多公司,爆一爆这个行业的状况吧……让后来人有所了解,也让猎头挖人挖的有点方向,起码和candidates聊天的时候不至 ...

  7. tomcat运行为什么要依靠jdk

    问题1:为什么要装jdk 因为tomcat是用java写的,所以运行需要JRE,就是JAVA运行时刻环境,所以必须通过安装JDK来得到这个运行环境,不装JDK装JRE也行,sun的网站上有下载.但是J ...

  8. UVa 11136 Hoax or what (STL)

    题意:有 n 天,每天有m个数,开始的前一天没有数据,然后每天从这个里面拿出一个最大的和最小的,求 n 天的最大的和最小的差值相加. 析:一看就知道用set啊,多简单的STL,不过要注意,开long ...

  9. RocketMQ 加载配置文件

    BrokerStartup.java // 指定配置文件 if (commandLine.hasOption('c')) { String file = commandLine.getOptionVa ...

  10. Swift:使用CAShapeLayer打造一个ProgresssBar

    ProgressBar是一个很小却在很多地方都会用到的东西.也许是网络连接,也许APP本身有很多东西需要加载的.默认的只有一个旋转的菊花,对于打造一款个性的APP这显然是不够的.这里就使用CAShap ...