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. Leetcode jump Game II

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  2. [机器学习] 虚拟机VMware中使用Ubuntu的联网问题

    在VMware中安装Ubuntu要解决两个问题: 1.VMware Tools安装使用 2.Ubuntu联网的虚拟机设置 1.VMware Tools安装 它的作用就是使用户可以从物理主机直接往虚拟机 ...

  3. PHP操作字符串 截取指定长度字符 移除字符串两侧 左侧 右侧指定字符 或空白字符 替换字符

    trim() trim() 函数移除字符串两侧的空白字符或其他预定义字符. <?php $str = "Hello World!"; echo $str . "&l ...

  4. Android 图标尺寸与设计

    样例和图解 外框:整体大小 ↑ 边框:图标留白大小 ↓ 图标:外图标的大小 ↑ 阴影:阴影特效大小 ↓ 图形:内图标的大小 ↑ 可选视图权重:使用两种类型的图形尺寸可以达到统一的视觉权重(可选),   ...

  5. WordPress 的 Google 字体问题解决办法

    在国内访问的时候,WordPress 里面引用的 google 字体可能会导致加载速度变得很慢. 要修改的地方有(我使用的版本是 4.0): wp-includes 里面的 script-loader ...

  6. [代码]label增加删除线

    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 100, 30)];    [self.view addSubvi ...

  7. python递归实现折半查找

    1.Python 基础教程版:(有点没想清楚) def search(sequence, number, lower=0, upper=None): if upper is None: upper = ...

  8. 多线程相关------互斥量Mutex

    互斥量(Mutex) 互斥量是一个可以处于两态之一的变量:解锁和加锁.只有拥有互斥对象的线程才具有访问资源的权限.并且互斥量可以用于不同进程中的线程的互斥访问. 相关函数: CreateMutex用于 ...

  9. 【iCore3双核心板】发布 iCore3 应用开发平台用户手册

    PDF手册下载地址:http://pan.baidu.com/s/1miBBYi8 iCore3应用开发平台购买地址:https://item.taobao.com/item.htm?spm=a1z1 ...

  10. Neil·Zou 语录二

    1 “Later equals never !”LeBlanc法则   2 爱情使人忘记时间,时间也会使人忘记爱情,不要让太多的昨天占据你的今天,请相信:是你的不管你怎样任性他都不会离开你:失去的其实 ...