Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 59516    Accepted Submission(s): 27708

 

Problem 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


Sample Output


题目大意与分析

每次给你一个数字n紧接着是n个数,代表棋子大小,每次要从第一个棋子开始,跳到最后一个,每次都要跳到比前一个大的棋子上,问跳过的棋子和最大为多少

题面写了这么多,其实就是求最大的上升子序列的和,把最长上升子序列的模板改一下就好了。

代码

#include<bits/stdc++.h>

using namespace std;

int a[],dp[],i,n,len,anss,j;

int main()
{
while(scanf("%d",&n),n!=)
{
len=;
anss=;
for(i=;i<n;i++)
{
cin>>a[i];
dp[i]=a[i];
}
for(i=;i<n;i++)
{
for(j=;j<i;j++)
{
if(a[i]>a[j])
{
dp[i]=max(dp[i],dp[j]+a[i]);
}
}
}
for(i=;i<n;i++)
{
anss=max(anss,dp[i]);
}
cout<<anss<<endl; }
}

HDU 1087 Super Jumping! Jumping! Jumping! (动态规划、最大上升子序列和)的更多相关文章

  1. HDU 1087 Super Jumping! Jumping! Jumping

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

  2. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...

  3. HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...

  4. HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *

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

  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! Problem Description Nowadays, a kind of chess game called “Super Ju ...

  7. HDU 1087 Super Jumping....(动态规划之最大递增子序列和)

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

  8. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)

    题意: 求解最大递增子序列. 例如:3 1 3 2 输入 3  个数 1 3 2 则递增子序列有 {1} {3} {2} {1 3} {1 2} ,故输出子序列的最大和 4 解题思路: x[n](n个 ...

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

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

随机推荐

  1. jquery which事件 语法

    jquery which事件 语法 作用:which 属性指示按了哪个键或按钮.大理石平台精度等级 语法:event.whic 参数: 参数 描述 event     必需.规定要检查的事件.这个 e ...

  2. C# 选择文件夹 选择文件

    选择文件 //选择文件 OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以选择多个文件 ...

  3. vue路由 routers的写法:require用与不用

    vue路由的写法有很多种,这里我只说routers的写法,一种是compcomponent后面直接写路径,另一种是用require的方式,来看代码 import Vue from 'vue' impo ...

  4. 用node.js搭建一个静态资源站 html,js,css正确加载 跳转也完美实现!

    昨天买了一个服务器想着用来测试一些自己的项目,由于是第一次建站,在tomcat,linux,node.js间想了好久.最终因为node搭建比较方便没那么麻烦就决定用node.js来搭建网站项目. 搭建 ...

  5. JavaWeb_(Jar)使用fastjson解析json和序列化对象

    菜鸟教程 传送门 JSON官网 传送门 fastjson插件下载 传送门 序列化[百度百科]:序列化 (Serialization)是将对象的状态信息转换为可以存储或传输的形式的过程.在序列化期间,对 ...

  6. postman如何绕过登录账户和密码验证,进行接口测试的方法

    实测于:2019.01.08 参考原文:https://yq.aliyun.com/ziliao/403942 一.获取登录后的cookie数据 1.打开浏览器: 2.启用开发者模式(F12键): 3 ...

  7. php的switch函数

    PHP Switch 语句 PHP If...Else PHP While 循环 switch 语句用于基于不同条件执行不同动作. Switch 语句 如果您希望有选择地执行若干代码块之一,请使用 S ...

  8. 14.多线程设计模式 - Master-Worker模式

    多线程设计模式 - Master-Worker模式 并发设计模式属于设计优化的一部分,它对于一些常用的多线程结构的总结和抽象.与串行相比并行程序结构通常较为复杂,因此合理的使用并行模式在多线程并发中更 ...

  9. Windows下如何安装Redis

    Redis可以从下面的github上面下载,当前的下载版本为3.2.100版本 https://github.com/MicrosoftArchive/redis/releases 这边都是64位的链 ...

  10. Eclipse控制台输出中文乱码问题的解决

    啥都不说,上图: 1.console控制台打印乱码 2.右键: Run As --> Run Configurations 3.找到common项,在“Encoding”栏,看到当前用的是默认“ ...