Super Jumping! Jumping! Jumping!

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
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
 
Sample Output
4
10
3
 
题目大意:求出序列从左到右,满足下一个数比上一个数大的条件,的最大序列和。
 
代码如下:
 # include <iostream>
# include<cstdio>
# define LL long long
using namespace std; int main()
{
int n,ans,max,i,j;
int s[],a[]; //s[i]表示最末尾是a[i]这个数的结果
bool flag;
while(scanf("%d",&n)&& n)
{
for(i=; i<n; i++)
{
scanf("%d",&a[i]);
s[i] = ;
}
s[] = a[];
for(i=; i<n; i++)
{
s[i] = a[i];
for(j=; j<i; j++)
{
if(a[i]>a[j] && s[j]+a[i]>s[i])
{
s[i] = s[j] + a[i];
}
}
}
max = ;
for(i=;i<n;i++)
{
if(s[i]>max)
max = s[i];
}
printf("%d\n",max);
}
return ;
}

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! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  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. 菜单设计器(Menu Designer)及其B/S,C/S双重实现(B/S开源)

    ERP/MIS开发 菜单设计器(Menu Designer)及其B/S,C/S双重实现(B/S开源)   一直从事ERP/MIS的开发工作,今天来展现一下菜单设计器的设计,及其用途,并对B/S部分代码 ...

  2. linux中文设置

    近期出现用户发邮件乱码问题,前面服务器刚刚切换过来,忘了装中文字体了. 本地调试在windows环境下,所以每次看都好的,于是我看了下linux服务器的编码,果然默认的不是中文字体,所以在生成pdf的 ...

  3. android studio简易了解第一部分

    1.如果还没下载 jdk,先把jdk下载,然后下载android studio 安装 百度 android studio ,百度软件中心可以下载. Android官网可以下载:     网址: htt ...

  4. WinForm中如何判断关闭事件来源于用户点击右上角的“关闭”按钮

    在C#的WinForm程序中,有的时候需要判定关闭请求从哪里发出来的.比如是用户点击了右上角的“关闭”按钮,还是调用了WinForm.Close()方法.最典型的是要知道点击右上角的“关闭”按钮发出的 ...

  5. hdu 5459 Jesus Is Here 数学

    Jesus Is Here Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  6. ListView Video

    com.baidu.frontia.FrontiaApplication ListView Video <item name="android:windowBackground&quo ...

  7. protocol buffer的简单使用

    protocol buffer是一个高效的结构化数据存储格式,用来结构化数据的序列化与反序列化.目前支持java.c++.Python 相对于json而言: 数据量跟小 其他的还没看出什么优势 下载地 ...

  8. android学习日记17--Gallery(画廊视图)

    一.Gallery 1.简述 Gallery有道翻译为画廊,就叫它画廊控件,主要用来可切换的图片展示,左右滑动可以选择上一张或下一张图片. 个人感觉蛮实用的,不过google貌似不推荐使用啊! 2.常 ...

  9. RHEL 7特性说明(七):编译程序及工具

    转载自:RedHat https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/7.0_Release ...

  10. CodeMachine Debugger Extension DLL

    http://www.codemachine.com/downloads.html http://www.codemachine.com/tool_cmkd.html#stack