HDU 1087 Super Jumping....(动态规划之最大递增子序列和)
Super Jumping! Jumping! Jumping!
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.
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.
#include<iostream>
#include<algorithm>
#include<cstring> using namespace std;
typedef long long LL;
const int maxn = ;
LL n, a[maxn], dp[maxn];
int main()
{
ios::sync_with_stdio(false);
while (cin >> n && n) {
memset(a, , sizeof(a));
memset(dp, , sizeof(dp));
for (int i = ; i <= n; i++)cin >> a[i], dp[i] = a[i];
for (int i = ; i <= n; i++)
for (int j = ; j < i; j++)
if (a[i] > a[j])
dp[i] = max(dp[i], dp[j] + a[i]);
LL ans = ;
for (int i = ; i <= n; i++)ans = max(ans, dp[i]);
cout << ans << endl;
}
return ;
}
HDU 1087 Super Jumping....(动态规划之最大递增子序列和)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- 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!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- 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:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- 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! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- 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!(动态规划)
题意: 求解最大递增子序列. 例如:3 1 3 2 输入 3 个数 1 3 2 则递增子序列有 {1} {3} {2} {1 3} {1 2} ,故输出子序列的最大和 4 解题思路: x[n](n个 ...
随机推荐
- Spring_Bean的生命周期
init-method="init" destroy-method="destory" 指定初始化和销毁方法 创建Bean后置处理器 <!-- 实现Bea ...
- SPARK Day04
广播变量和累加器 广播变量 广播变量理解图 广播变量使用 val conf = new SparkConf() conf.setMaster("local").setAppName ...
- mongoDB端口启动失败原因
删除以下文件: (所以数据会丢失,需要重新创建数据库)
- pl/sql基础知识—定义并使用变量
n 介绍 在编写pl/sql程序是,可以定义变量和常量:在pl/sql程序中包括有: ①标量类型(scalar) ②复合类型(composite) ③参照类型(reference) ④lob(lar ...
- Linux下的python安装
centos7安装python3 以及tab补全功能 1.安装python3 1.1下载python源码包 网址:https://www.python.org/downloads/release/ ...
- 命名实体识别学习笔记——使用Ltp
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/xuewenstudy/article/d ...
- shell日常使用整理
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wzzfeitian/article/details/30995303 基本常识 1.变量命名规则: ...
- Validation异常:No validator could be found for constraint '.....' validating type 'java.lang.Integer'.
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'java ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制 代码工程地址: https://gi ...
- MySQL的安装问题总结--终极解决方案
MySQL安装 选择:custom 自定义 更改路径 安装到其他盘 选择:launch configuration finish 进行配置 如果忘记选择 找 "E:\Program Fil ...