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. Java 对象序列化(Serialization Object)

    官网文档:https://docs.oracle.com/javase/tutorial/jndi/objects/serial.html 优秀博客: http://www.cnblogs.com/g ...

  2. matlab练习程序(碎片)

    这个算法是对photoshop中滤镜->像素化->碎片这个功能的学习. PS这个功能好像不带参数,不过我这里有滤波半径r可以进行控制. 因为我是看效果猜算法的,效果肯定有所区别. 我的想法 ...

  3. Codeforces Beta Round #89 (Div. 2) E. Bertown roads(Tarjan、边双连通分量)

    题目链接:http://codeforces.com/problemset/problem/118/E 思路:首先要判断图是否是边双连通,这个Tarjan算法可以判断,若low[v] > dfn ...

  4. 两个本地(localhost)html文件之间的传值

    什么是iframe? iframe 元素会创建包含另外一个文档的内联框架(即行内框架).可以理解为把iframe解释成“浏览器中的浏览器“ 在IE中: document.frames[i].docum ...

  5. Oracle资源

    ORACLE 10g下载地址 oracle 下载还需要用户名我自己注册了个方便大家使用下载 user:1603869780@qq.compass:qwe123QWE现在直接点击不能下载了 要经过ora ...

  6. XCL-Charts图表库简要教程及常见问题

    这个Andriod图表库项目从开始至现在,热情消耗几近殆尽.还好已基本实现我想做的那些东西.趁还剩下点兴趣,把一些点非常简单的归纳一下. 所支持的图表类型: 基类                   ...

  7. Java ClassLoader基础及加载不同依赖 Jar 中的公共类

    转载自:最新内容及最清晰格式请见 http://www.trinea.cn/android/java-loader-common-class/ 本文主要介绍 ClassLoader 的基础知识,Cla ...

  8. express-18 路由

    简介 路由是网站或Web服务中最重要的一个方面:路由是将请求(由URL和HTTP方法指定)路由到处理它们的代码去的一种机制. 路由过去是基于文件的,这很简单,但不灵活. IA 是指内容的概念性组织.在 ...

  9. 浩瀚技术助力批发零售商户实现PDA移动POS打印扫描进销存信息化管理

    批发零售商户其各门店销售品种多,销售量大,在市场上占据巨大的份额,随着各门店的不断扩展,基层的销售管理并不尽如意,传统的进销存管理软件安装在PC端,无法满足有现有的业务支撑,面对当前现状,移动进销存管 ...

  10. Windows下安装 使用coreseek

    1.安装 1.01:到官网下载 coreseek-3.2.14 1.01_1 原理 缓存服务器: 准备数据 来自数据库 配置连接  生成索引 开启服务 流程:用户-> web->sphin ...