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. 

InputInput 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. 
OutputFor 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
像这样对顺序有要求的DP,可以想一下最长递增子序列思路
#include <iostream>
#include <string>
#include<cstring>
#include<cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 1004
typedef long long LL;
/*
从下向上叠箱子,可以看作求最长递增子序列的和.
*/
int main()
{
int n,a[MAXN],dp[MAXN];
while(scanf("%d",&n),n)
{
int ans = -;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
dp[i] = a[i];
}
for(int i=;i<n;i++)
{
for(int j=;j<i;j++)
{
if(a[i]>a[j])
dp[i] = max(dp[i],dp[j]+a[i]);
ans = max(dp[i],ans);
}
}
cout<<ans<<endl;
}
}

E - Super Jumping! Jumping! Jumping! DP的更多相关文章

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

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

  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! (简单dp)

    Super Jumping! Jumping! Jumping! 搬中文ing Descriptions: wsw成功的在zzq的帮助下获得了与小姐姐约会的机会,同时也不用担心wls会发现了,可是如何 ...

  4. 杭电1087 Super Jumping! Jumping! Jumping!(初见DP)

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

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

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

  6. HDU-1087-Super Jumping! Jumping! Jumping!(线性DP, 最大上升子列和)

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

  7. Codeforces Round #598 (Div. 3) C. Platforms Jumping 贪心或dp

    C. Platforms Jumping There is a river of width n. The left bank of the river is cell 0 and the right ...

  8. CodeForces - 512B Fox And Jumping[map优化dp]

    B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

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

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

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

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

随机推荐

  1. Math teacher's homework

    Title:[Math teacher's homework] Description 题目大意:给你n个数m1,m2...mn,求满足X1 xor X2 xor ... xor Xn=k,0< ...

  2. Windows环境下使用Netsh命令快速切换IP配置

    不同的内网环境需要使用不同的IP配置,频繁切换令人发狂,因此搜索了快速切换IP配置的方法. Netsh interface IP Set address "以太网" Static ...

  3. 231 Power of Two 2的幂

    给定一个整数,写一个函数来判断它是否是2的幂. 详见:https://leetcode.com/problems/power-of-two/description/ Java实现: class Sol ...

  4. Geoserver常见问题总结

    原文地址 :http://blog.csdn.net/mygisforum/article/details/8249093 http://www.cnblogs.com/wang985850293/p ...

  5. javascript学习之Date对象

    前几天学习了一下date对象,于是写了一个简单的时间显示放到博客页面里(位于右上角),类似这样的效果,时:分:秒 xxxx年xx月xx日. 下面来说一下具体实现步骤. 首先,既然date是一个对象,那 ...

  6. jdbc 实现分页

    jdbc 实现分页,的实现 原理这个就不介绍了.. 总之是用jdbc 的游标移动 package com.sp.person.sql.util; import java.sql.Connection; ...

  7. jQuery.fn.extend和jQuery.extend

    <script src="http://www.cssrain.cn/demo/JQuery+API/jquery-1[1].2.1.pack.js" type=" ...

  8. arx代码片段

    ObjectARX代码片段二   转载自网络 一  在ARX中禁用AutoCAD的某个命令 以LINE命令为例,在程序中加入下面的一句即可禁用LINE命令: acedCommand(RTSTR, &q ...

  9. Leetcode 498:对角线遍历Diagonal Traverse(python3、java)

    对角线遍历 给定一个含有 M x N 个元素的矩阵(M 行,N 列),请以对角线遍历的顺序返回这个矩阵中的所有元素,对角线遍历如下图所示. Given a matrix of M x N elemen ...

  10. JAVA基础数组

    数组: 数组是一种容器 存储同一类型的一组数据(必须是 类型相同的一组数据) 定义数组的公式:(有两种) 1.静态定义      1)数据类型[ ] 数组名 = {元素1,元素2,元素3,元素4,元素 ...