Super Jumping! Jumping! Jumping!

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

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
 
题目大意:用一句话总结就是 输入一个整数数列,输出该数列的最大上升子序列和。
 
解题思路:刚接触到这题的时候没什么思路 看了看网上的题解发现只是一个水DP(赶脚自己好菜啊~~)
     只要把状态转移方程怼出来就可以了。对于这题来说可以定义一个dp数组
     dp[i] 表示前i个整数组成的子串的最大上升子序列和
     状态方程:dp[i]=max{dp[j]}+a[i]; 其中,0<=j<i,a[i]>a[j] ;
 
 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int n;
long long a[],dp[]; // dp[i] 储存从0到i的最大上升子序列的和
long long LIS() // 最大上升子序列和
{
int i,j;
long long sum = , maxx;
for (i = ; i < n; i ++)
{
dp[i] = a[i]; // dp[i]的初值为a[i]
maxx = ;
for (j = ; j < i; j ++) // 找出i之前的最大dp[i](并保证a[j] < a[i])
{
if (a[j] < a[i])
maxx = max(dp[j],maxx);
}
dp[i] += maxx;
sum = max(sum,dp[i]); // sum为最大上升子序列的和
}
return sum;
}
int main ()
{
while (scanf("%d",&n),n)
{
for (int i = ; i < n; i ++)
scanf("%lld",&a[i]);
printf("%lld\n",LIS());
}
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!(求LSI序列元素的和,改一下LIS转移方程)

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

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

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

  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 最长上升子序列和)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...

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

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

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

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

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

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

  9. HDU 1087 Super Jumping! Jumping! Jumping! (DP)

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

  10. HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)

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

随机推荐

  1. [NodeJS]Jenkins-cli

    使用npm 包nestor 触发jenkins job, 达到命令行管理Jenkins功能. 1. install nestor : npm install -g nestor 2. set JENK ...

  2. python 小练习('''产生了多少个对象''')('''模拟两个英雄,昵称,攻击力,生命值''')

    '''小练习 计数器,产生了多少个对象''' # class Student: # school = 'luffycity' # count = 0 # def __init__(self, name ...

  3. VR内容是如何制作的!

    VR全景视频作为一种新型的视频方式,其震撼效果是毋庸置疑的.目前市场上的VR全景视频也不在少数,越来越多的人能够欣赏到精彩的内容. 首先呢, VR内容场景的呈现分为两种情况: 1.实景拍摄 2.3D建 ...

  4. 【TensorFlow】-精选Github开源项目

    转至:http://www.matools.com/blog/1801988 留底做个记录,有空在做验证. TensorFlow源码 https://github.com/tensorflow/ten ...

  5. 对接京东jos遇到的坑 记录一下。方便查询

    坑很多,有一些忘记了.文档乱的很,有问题可以私信我一下我看能不能想起来. 坑一.添加商品接口. {"error_response": {"code":" ...

  6. Oracle 维护数据的完整性 一 约束

    简介:约束用于确保数据库满足特定的商业规则.在Oracle中,约束包括以下几种: 1.not null      非空约束       该劣质不能为null 2.unique       唯一约束   ...

  7. Xshell关闭导致jar服务终止,使Jar在CentOS后台运行

    环境:Xsehll6,CentOS7 在项目文件夹新建一个runjar.sh 在sh中写入(举例说明) nohup java -Dfile.encoding=UTF- -jar fin-mgmt-.j ...

  8. SIMD

    SIMD 概述 数据类型 静态方法:数学运算 静态方法:通道处理 静态方法:比较运算 静态方法:位运算 静态方法:数据类型转换 实例方法 实例:求平均值 概述 SIMD(发音/sim-dee/)是“S ...

  9. 使用Charles为Android设备抓取https请求的包

    之前开发的Android APP使用的都是http请求,之后改成了https,就出现了以下情况,无法正常读取抓取的内容 找了好多资料说法大概差不多,照着弄,结果出现如下情况,后来发现这种情况其实是手机 ...

  10. Centos 下搭建FTP上传下载服务器

    首先判断你服务器上是否安装了vsftpd 安装vsftpd #yum -y install vsftpd   安装完成之后就要重启vsftpd服务 到vsftpd的主配置文件里面 把这个改为NO 默认 ...