(最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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
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
Sample Input
Sample Output
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<algorithm>
using namespace std; #define N 1000
#define oo 0x3f3f3f3f int main()
{
int n, a[N], sum[N]; while(scanf("%d", &n), n)
{
int i, j; memset(a, , sizeof(a));
memset(sum, , sizeof(sum)); for(i=; i<=n; i++)
scanf("%d", &a[i]); /** 我决定了要好好学 dp 这次写自然是要自己感悟的,自己想真的不容易,
尽管写过,尽管很简单,我也只是无奈,不好想 我又开了个数组 sum[], 里面记录的是从 1 开始到 i 最大的上升序列的和
既然 sum[i] 里记录的是最大的从 1 到 i 的值,那么每次比较 a[i] 和 a[j] 的大小
如果 a[i] 比 a[j] 大的话,就需要选 sum[i] 和 sum[j]+a[i] 的最大值 最后在 sum 中选个最大值就 OK 啦!!! **/ for(i=; i<=n; i++)
{
sum[i] = a[i];
for(j=; j<=i; j++)
{
if(a[i]>a[j])
sum[i] = max(sum[i], a[i]+sum[j]);
}
} int Max = -oo; for(i=; i<=n; i++)
Max = max(Max, sum[i]); printf("%d\n", Max);
}
return ;
}
(最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087的更多相关文章
- 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
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1069&&HDU 1087 (DP 最长序列之和)
H - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- 怒刷DP之 HDU 1087
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- 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!(最大上升子序列和)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 最长上升子序列模板 hdu 1087 Super Jumping! Jumping! Jumping!
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...
- HDU 1087 Super Jumping! Jumping! Jumping! (动态规划、最大上升子序列和)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- ansible之条件语句when
注册变量: 变量的另一个用途是将一条命令的运行结果保存到变量中,供后面的playbook使用.例如: - hosts: webservers tasks: - shell: /usr/bin/foo ...
- delphi 中判断对象是否具备某一属性
Uses TypInfo; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); ...
- Dotfuscator Professional Edition获取代码发布和混淆代码
1 Dotfuscator Professional Edition 4.9 破解版 下载地址:http://www.pc0359.cn/downinfo/39815.html 备份地址:C:\D\9 ...
- 类的"魔法"方法
1. __init__()方法 <1>使用方式 def 类名: #初始化函数,用来完成一些默认的设定 def __init__(): pass 总结1 当创建Car对象后,在没有调用__i ...
- JFR 与 JProfilter Jvmisualvm
只有JFR 是可以在生产环境使用 采用C++独立写的采样手机功能 而 JProfilter/JVisualvm 都只能在测试环境下使用 使用instrument 机制 ,还有debug 框架 最早是 ...
- chrome 调试参数大全
一.鼠标事件监控: monitorEvents(document, ["scroll"]); monitorEvents($('#action-button'), ["m ...
- Springboot IDEA eclipse 打包
在开发springboot项目中,我们会进行打包发布项目,springboot推荐以jar包方式发布,相对之下 jar运行的效率比起war项目快很多. 打包切记: 1.查看项目里面有没有其他的main ...
- seleniumIDE的实践
浏览器:1.Firefox setup35.0.12.安装完成后设置菜单栏---安装完浏览器,鼠标定位在浏览器的状态栏,然后点击鼠标右键,点击勾选菜单栏,这时候就有菜单栏出现了 3.关闭浏览器自动更新 ...
- window环境mysql解压版配置
1.下载并解压 到官网下载mysql-5.5.10-win32.zip,然后将mysql解压到任意路径,如:C:\mysql-5.5.10-win32 2.设置环境变量 打开计算机->属性-&g ...
- Python str() 函数
Python str() 函数 Python 内置函数 描述 str() 函数将对象转化为适于人阅读的形式. 语法 以下是 str() 方法的语法: class str(object='') 参数 ...