E. Super Jumping! Jumping! Jumping!

Time Limit: 1000ms

Memory Limit: 32768KB

64-bit integer IO format:      Java class name:

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 <cstdio>
#include <iostream>
#include<cstring>
using namespace std;
const int inf = ;
int main()
{
int n,a[],sum[],maxn;
while(scanf("%d",&n)&&n)
{
memset(sum,,sizeof(sum));
for(int i = ;i<=n;i++)
scanf("%d",&a[i]);
for(int i=;i<=n;i++)
{
maxn=-inf;
for(int j=;j<i;j++)
if(a[i]>a[j])
maxn=max(maxn,sum[j]);
sum[i]=maxn+a[i];
}
maxn=-inf;
for(int i=;i<=n;i++)
{
if(sum[i]>maxn) maxn=sum[i];
}
printf("%d\n",maxn);
}
return ;
}

Super Jumping! Jumping! Jumping!——E的更多相关文章

  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. Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...

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

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

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

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

  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. php 以图搜图

    感知哈希算法count < =5 匹配最相似count > 10 两张不同的图片var_dump(ImageHash::run('1.jpg’, '2.jpg’)); <?php c ...

  2. HR外包系统 - 账款

    01 账款-服务费,注意多币种以及收款对象和联系人的设置 02 代收代付,注意多币种以及收款对象和联系人的设置 03 账单要保存服务费计算的整个过程,便于后面出报表和数据分析 04 出报表时,要考虑 ...

  3. C语言中的位操作(14)--反转比特位

    本篇文章主要讲述几种反转比特位的方法: 将一个32位数:abcd efgh 转置为hgfe dcba 1.常规方法 unsigned int v; // 目标待转置数 unsigned int r = ...

  4. 安卓app设计规范整理和Android APP设计篇(转)

    随着安卓智能手机不停的更新换代.安卓手机系统越来越完美,屏幕尺寸也越来越大啦!比如最近小米的miui 6的发布和魅族手机系统的更新等等. 以小米MIUI6的安卓手机来说,MIUI6进行了全新设计,坚持 ...

  5. 允许webservice远程测试

    System.Web节点下添加 <webServices> <protocols> <add name= "HttpPost"/> <ad ...

  6. POJ 1655 Balancing Act 树的重心

    Balancing Act   Description Consider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. ...

  7. canvas加载进度条

    <!DOCTYPE html> <html><head><meta http-equiv="Content-Type" content=& ...

  8. JS获得鼠标位置

    <body> <script> function mouseMove(ev) { ev = ev || window.event; var mousePos = mouseCo ...

  9. XSS 跨站脚本攻击之构造剖析(二)

    1.利用字符编码 (1)字符编码在跨站脚本中经常运用到,透过这种技巧,不仅能让XSS代码绕过服务端的过滤,还能更好的隐藏ShellCode (2)使用一个XSS编码工具,以便对字符串进行十进制和十六进 ...

  10. SQL初级第三课(上)

    先建立一个表 create table Student                 --学生(Sno          char(3) primary key ,  --学生学号Sname     ...