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 <stdio.h>
#include <algorithm>
using namespace std;
const int maxn=;
int num[maxn],sum[maxn];
int main()
{
int n,i,j,ans;
while(scanf("%d",&n)!=EOF&&n)
{
for(i=;i<=n;i++)
scanf("%d",&num[i]);
sum[]=num[];
ans=sum[];
for(i=;i<=n;i++)
{
sum[i]=num[i];
for(j=;j<i;j++)
{
if(num[j]<num[i]&&sum[j]+num[i]>sum[i])
sum[i]=sum[j]+num[i];
}
if(ans<sum[i])
ans=sum[i];
}
printf("%d\n",ans); }
return ;
}

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. DP专题训练之HDU 1087 Super Jumping!

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

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

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

  5. Super Jumping! Jumping! Jumping!——E

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

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

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

  7. HDU 1087 Super Jumping! Jumping! Jumping

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

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

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

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

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

随机推荐

  1. 【转】前端工程筹建NodeJs+gulp+bower

    转自:http://www.myexception.cn/javascript/1781968.html npm nodejs 安装过程中会自动安装npm,nodejs安装程序会在环境变量中添加两个变 ...

  2. Spring任务调度之Spring-Task

    一.前言 上面两篇介绍了在Spring 中使用Timer与Quartz,本篇将介绍Spring3.0以后自主开发的定时任务工具,spring task,可以将它比作一个轻量级的Quartz,而且使用起 ...

  3. Gitbook简易教程

    简介 GitBook 是一个基于 Node.js 的命令行工具,可使用 Github/Git 和 Markdown 来制作精美的电子书.GitBook支持输出以下几种文档格式 静态站点:GitBook ...

  4. Jmeter性能测试 入门

    Jmeter是一款优秀的开源测试工具, 是每个资深测试工程师,必须掌握的测试工具,熟练使用Jmeter能大大提高工作效率. 熟练使用Jmeter后, 能用Jmeter搞定的事情,你就不会使用LoadR ...

  5. i2c协议

    i2c协议 http://blog.csdn.net/g_salamander/article/details/8016698 总线设备驱动模型 http://blog.csdn.net/u01395 ...

  6. scrapy爬虫笔记(二)------交互式爬取

    开始网页爬取:(1)交互式爬取 首先,我们使用scrapy建立起爬虫的框架.在命令行中输入 scrapy shell “url” 如:scrapy shell “http://www.baidu.co ...

  7. 畅通工程——D

    D. 畅通工程 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可).经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的 ...

  8. bug2--工程性错误

    1问题场景:图片上传失败,打印log.http header 有数据.不报错,通过流写入文件后,文件被创建,但是大小为0kb. 执行:df -h 发现linux的磁盘 used 100%. 原来是没有 ...

  9. delphi URL 编码的转换

    先介绍一下,Delphi中处理Google的URL编码解码,其中就会明白URL编码转换的方法的 从delphi的角度看Google(谷歌)URL编码解码方式 在网上搜索了一下,似乎没有什么关于goog ...

  10. Python 随机数生成总结

    random.uniform(a, b),返回[a,b]之间的浮点数 random.randint(a, b),返回[a,b]之间的整数 random.randrange([start], stop[ ...