Super Jumping! Jumping! Jumping!

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Appoint description: 
System Crawler  (2015-09-05)

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
 
 
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
using namespace std; const int SIZE = ;
const int INF = 0x7ffffff0;
struct Node
{
int val,max;
}DP[SIZE]; int main(void)
{
int n,ans,box,max; while(scanf("%d",&n) != EOF && n)
{
ans = -INF;
for(int i = ;i < n;i ++)
{
scanf("%d",&box);
max = ;
for(int j = ;j < i;j ++)
if(DP[j].max < box && DP[j].val > max)
max = DP[j].val;
DP[i].max = box;
DP[i].val = max + box;
ans = ans > DP[i].val ? ans : DP[i].val;
}
printf("%d\n",ans);
} return ;
}

怒刷DP之 HDU 1087的更多相关文章

  1. 怒刷DP之 HDU 1257

    最少拦截系统 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  2. 怒刷DP之 HDU 1160

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  3. 怒刷DP之 HDU 1260

    Tickets Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  4. 怒刷DP之 HDU 1176

    免费馅饼 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  5. 怒刷DP之 HDU 1114

    Piggy-Bank Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit S ...

  6. 怒刷DP之 HDU 1069

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. 怒刷DP之 HDU 1024

    Max Sum Plus Plus Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. 怒刷DP之 HDU 1029

    Ignatius and the Princess IV Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64d &a ...

  9. 【DP】HDU 1087

    HDU 1078 Super Jumping! Jumping! Jumping! 题意: 有这么个游戏,从start到end(自己决定在哪停下来)连续跳圈,中间不能空一个圈不跳,圈里的数字必须比你上 ...

随机推荐

  1. UVA1151

    //感觉刘汝佳老师的思维真的太厉害了orz /*摘录书上的一段话: 只需一个小小的优化即可降低时间复杂度:先求一次原图(不购买任何套餐)的最小生 成树,得到n-1条边,然后每次枚举完套餐后只考虑套餐中 ...

  2. 二进制程序分析工具Pin在Windows系统中的安装和使用方法

    这篇日志其实很弱智,也是因为换了新电脑,实验环境不全(当然,做这个实验我是在虚拟机里,因为接下来想拿些恶意代码的数据),所以这里记录一下在Windows下怎么安装和使用Pin这个程序分析领域最常用的工 ...

  3. USB DATA Toggle

    For bulk and interrupt transfers, the data toggle resets <0> only on Set Configuration, Set In ...

  4. Delphi / C++ Builder 使用 UDT ( UDP-based Data Transfer ) 4.11

    添加 src/*.cpp 到工程, 修改 Directories and Conditionals, 添加 WIN32 UDT_EXPORTS udt.h 需要 #pragma link " ...

  5. [Jobdu] 题目1531:货币面值

    题目描述: 小虎是游戏中的一个国王,在他管理的国家中发行了很多不同面额的纸币,用这些纸币进行任意的组合可以在游戏中购买各种装备来提升自己.有一天,他突然很想知道这些纸币的组合不能表示的最小面额是多少, ...

  6. Cocos2d-x--开发参考资料

    1.CocoStudio使用指南 所用版本:CocoStudio v3.0.0 Cocos2d-x1.5b 自己网上查找并整理的一些资料,留下做个纪念,也希望对有需要的人有点帮助 链接地址:http: ...

  7. 大话设计模式C++实现-第22章-桥接模式

    一.UML图 二.概念 桥接模式(Bridge):将抽象部分与它的实现部分分离,使他们都能够独立地变化. 三.说明 为什么叫"桥接模式"? 如上所看到的的UML图中,有一个聚合线, ...

  8. FindMe

    https://github.com/hongdong/FindMe_Android https://github.com/hongdong/FindMe_Server https://github. ...

  9. [终极精简版][图解]Nginx搭建flv mp4流媒体服务器

    花了我接近3周,历经了重重问题,今日终于把流媒体服务器搞定,赶紧的写个博文以免忘记... 起初是跟着网上的一些教程来的,但是说的很不全面,一些东西也过时不用了(比如jwplayer老版本).我这次是用 ...

  10. Winform开发--控件

    WinForm控件开发总结目录 WinForm控件开发总结目录 WinForm控件开发总结(一)------开篇 WinForm控件开发总结(二)------使用和调试自定义控件 WinForm控件开 ...