hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)
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
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.
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.
and one line one case.
#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!(最大上升子序列和)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- DP专题训练之HDU 1087 Super Jumping!
Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...
- hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP)
C - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
随机推荐
- 矩阵快速幂--51nod-1242斐波那契数列的第N项
斐波那契额数列的第N项 斐波那契数列的定义如下: F(0) = 0 F(1) = 1 F(n) = F(n - 1) + F(n - 2) (n >= 2) (1, 1, 2, 3, 5, 8, ...
- 使用docker部署STF服务(CentOS环境)
一.安装docker环境 更新软件 sudo yum update 执行安装 sudo yum install docker 查看docker镜像 sudo docker images 二.拉取相关镜 ...
- ASP.NET中类的多语言编译
App_Code 文件夹中同时使用多种语言编程的方法 在web.config文件里,加入如下的配置 <configuration> <system.web> <comp ...
- jenkins+Publish Over SSH 提示:Transferred 0 file(s)
之前公司用jekins来进行自动化发布,现在公司因没有运维,所以自己学习.并搭建了一个jenkins的环境来进行项目自动化部署. 不料在最后连接ssh后部署时,一直提示Transferred 0 fi ...
- app唤起的完美解决方案,及阻止浏览器的默认弹窗行为
https://stackoverflow.com/questions/10237031/how-to-open-a-native-ios-app-from-a-web-appvar frame = ...
- UnxUtils让windows下的dos命令变为linux下的命令
一.UnxUtils UnxUtils是一个可以支持在Windows下使用linux命令的工具,用习惯了linux之后,感觉Windows的dos命令实在是太难用了,发现了这个工具,非常的小,装了它之 ...
- CentOS7 wget 安装Redis,开机启动配置
安装 GCC yum install gcc yum install tcl 安装wget yum install wget 1. 下载Redis wget http://download.red ...
- QQ游戏--捕鱼假日竞技港对抗岛自动刷贝壳辅助使用教程和下载地址
首先解压缩到D盘根目录 再进入buyujiari文件夹双击 然后打开QQ游戏,进入竞技港-->对抗岛,到达开始准备的界面 再打开 辅助.exe 360对按键精灵的一个文件会提示病毒,可不用理会 ...
- [转载]java.ByteArrayInputStream与ByteArrayOutputStream再次理解
一次看到ByteArrayOutputStream的时候是在Nutch的部分源码,后来在涉及IO操作时频频发现这两个类的踪迹,觉得确实是很好用,所以把它们的用法总结一下. ByteArrayOutpu ...
- 32位和64位系统内核函数调用从ZwProtectVirtualMemory到NtProtectVirtualMemory
0x01 前言 我们知道R3层中,Zw系列函数和Nt系列函数函数是一样的,但是在内核Zw系列函数调用了Nt系列函数,但是为什么要在内核设置一个Zw系列函数而不是直接调用Nt函数呢?Zw系列函数又是怎么 ...