(最大上升子序列) 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 ...
随机推荐
- Linux启动提示Kernel panic - not syncing: Attempted to kill init解决办法
系统类型:CentOS 6.5(x64) 启动提示:Kernel panic - not syncing: Attempted to kill init 解决办法: 系统启动的时候,按下‘e’键进入g ...
- 通过IP地址进行精准定位
可能会遇到这样的问题,服务器或者系统经常被扫描,通过IP地址我们只能查到某一个市级城市,如下图: 当我们想具体到街道甚至门牌号,该怎么办??? 偶然间发现百度地图有高精度IP定位API的接口,通过该接 ...
- out对象以及网上答题系统
out对象的主要功能是向客户输出响应信息,其主要方法为“print()”,可以输出任意类型的数据,HTML标记可以作为out输出的内容. 代码: 程序截图
- ubuntu修改运行级别方法
Ubuntu系统设置启动级别的问题,因自己以前遇到过,故做过笔记记录了下来:Ubuntu.Debian系列与RedHat.CentOS启动级别含义有所区别:Ubuntu系列运行级别定义如下:0 – H ...
- Spring Boot AOP
AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是Spring框架中的一个重要内容,它通 ...
- day7:vcp考试
Q121. An ESXi 6.x host in the vCenter Server inventory has disconnected due to an All Paths Down (AP ...
- Nginx配置杂记(转)
转至:http://www.cnblogs.com/kuangke/p/5619400.html Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器,相较 ...
- css浮动的元素居中
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- svn回退版本/取消修改
取消对代码的修改分为两种情况: 第一种情况:改动没有被提交(commit). 这种情况下,使用svn revert就能取消之前的修改. svn revert用法如下: # svn revert [ ...
- RNA-seq连特异性
RNA-seq连特异性 Oct 15, 2015 The strandness of RNA-seq analysis 前段时间一直在研究关于illumina TrueSeq stranded RNA ...