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 ...
随机推荐
- 进阶篇:4.2)DFA设计指南:优化装配工序
本章目的:针对每一个装配工序,运用DFA进行优化. 1.前言 工序的优化在产品的精简之后. 这个是作者的实际做完DFA后得出的结论.原因倒是很简单,一个精密的产品,哪怕只是优化了一个零件,对整体的装配 ...
- js对函数参数的封装
对函数参数的封装 一个原始函数有n个参数,用wrap对函数进行封装,生成一个新的函数,当给它传入参数数量为n的时候,将执行原始函数,否则不执行 //函数封装 function wrap(func){ ...
- CAN2.0A帧格式 与 LIN帧格式 简单说明
一.标准的2.0A帧格式 各字段解释:SOF帧开始标志比特是一个显性比特(0),由一个或多个准备发送帧的节点传输.SOF标志着帧的开始(或仲裁发送帧的权利),并用于“硬同步”总线上的设备.只有在开始发 ...
- mysql 设置默认时间为now()
TIMESTAMP的变体1,TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP在创建新记录和修改现有记录的时候都对这个数据列 ...
- sort sorted() reverse() reversed() 的区别
sort()是可变对象(字典.列表)的方法,无参数,无返回值,sort()会改变可变对象,因此无需返回值.sort()方法是可变对象独有的方法或者属性,而作为不可变对象如元组.字符串是不具有这些方法的 ...
- Java_方法的定义以及分类
什么叫方法? 方法也叫做函数,实现某个功能 方法分类: 系统提供的方法: 常用的系统提供的方法:如:nextInt() next() nextDouble() print println()..... ...
- typescript -- ts
算是强类型语言,javascrpt是弱类型语言,是指对数据的类型的处理,弱类型语言的特点有时候只是在支行的时候才告诉你出错了,但写的时候你是查觉不到的 ts也是以es5-7为语法标准的,开发的算是另外 ...
- LeetCode 100.相同的树(C++)
给定两个二叉树,编写一个函数来检验它们是否相同. 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的. 示例 1: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1 ...
- 《JavaScript语言精粹》读书笔记
第三章:对象 //1.定义一个方法 method Function .prototype.method=function(name, func){ this.prototype[name]=func; ...
- oracle系统包——dbms_random用法
oracle中随机数的包的源文件目录:{oracle_home}\rdbms\admin\dbmsrand.sql 1.返回0~1间的随机数(包括0和1)sql> select dbms_ran ...