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): 32564 Accepted Submission(s):
14692
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.
4 1 2 3 4
4 3 3 2 1
0
| 下标i | 0 | 1 | 2 | 3 | 4 | 5 |
| a[i] | ||||||
| sum[i] | 3 | 2 | 7 | 2 | 5 | 13 |
| ans | 0 | 3 | 7 | 7 | 5 | 13 |
#include <iostream>
#include <cstdio>
//#define max(a,b) a>b ? a:b
using namespace std; int main()
{
int n;
int a[];//存储每一个数
int sum[];//存储这个数之前的递增子序列的和
int ans;//一直存储最大的和
while(scanf("%d",&n)!=EOF && n!=){
for(int j1=;j1<n;j1++){
scanf("%d",&a[j1]);
}
sum[]=a[];
ans=;
for(int i= ;i<n;i++){
ans=;
for(int j=;j<i;j++){
if(a[i]>a[j]){
ans=max(sum[j],ans);//重要代码!
}
}
sum[i]=a[i]+ans;//重要代码!
}
ans=-;
for(int i=;i<n;i++){
if(ans<sum[i]){
ans=sum[i];
}
}
cout<<ans<<endl;
}
return ;
}
我是代码,请点我!!!
不懂的时候,告诉自己,再坚持一下,再坚持一下,这个题就看懂了。
刚开始不会做,然后百度,看了好久才看明白这个题的方法~~~~(>_<)~~~~
HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1257 最少拦截系统 最长递增子序列
HDU 1257 最少拦截系统 最长递增子序列 题意 这个题的意思是说给你\(n\)个数,让你找到他最长的并且递增的子序列\((LIS)\).这里和最长公共子序列一样\((LCS)\)一样,子序列只要 ...
- 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!(求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 ...
- HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- 题解报告:hdu 1087 Super Jumping! Jumping! Jumping!
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...
- 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个 ...
- HDU 1087 Super Jumping....(动态规划之最大递增子序列和)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
随机推荐
- mac os x常用快捷键及用法
最近在研究mac os x系统,开始入手,很不习惯,和windows差别很大,毕竟unix内核.使用中总结了一些使用快捷键(默认),持续更新,欢迎大家补充.1.撤销:command+z 保存:comm ...
- oracle基本语句
ALTER TABLE SCOTT.TEST RENAME TO TEST1--修改表名 ALTER TABLE SCOTT.TEST RENAME COLUMN NAME TO NAME1 --修改 ...
- KMP 算法总结
KMP算法是基本的字符串匹配算法,但是代码实现上有一些细节容易错.这篇随笔将认真总结一下. KMP算法的核心是: The KMP algorithm searches for occurrences ...
- Extjs Form用法详解(适用于Extjs5)
Extjs Form是一个比较常用的控件,主要用来显示和编辑数据的,今天这篇文章将介绍Extjs Form控件的详细用法,包括创建Form.添加子项.加载和更新数据.验证等. 本文的示例代码适用于Ex ...
- jquery发送ajax请求返回数据格式
jquery向服务器发送一个ajax请求后,可以返回多种类型的数据格式,包括:html,xml,json,text等. 1.html格式的数据 "<div class='comment ...
- Redis介绍以及安装(Linux与windows)
1.liunux系统 redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了memcached的 不足,它支持存储的value类型 ...
- java如何去调用C++的方法详解
这是一个调用c++ jni 的列子 首先写一个GoodLuck 类,里面包含native本地方法,这是用作C/C++实现的.也就是用C/c++实现java的native 方法.public class ...
- thinkphp中page方法
page方法也是模型的连贯操作方法之一,是完全为分页查询而诞生的一个人性化操作方法. 用法 我们在前面已经了解了关于limit方法用于分页查询的情况,而page方法则是更人性化的进行分页查询的方法,例 ...
- 微信公众平台回复过了怎么不能再次回复?亲们要注意查看"公众平台回复用户消息时限变更通知"的公告啊
有网友一直在问“微信公众平台回复过了怎么不能再次回复?”,其实这个是微信公众平台订阅号设置的一个时间限制,一般都会提示:由于该用户48小时未与你互动,你不能再主动发消息给他.直到用户下次主动发消息给你 ...
- Android EditText 文本框实现搜索和清空效果
前言 本文实现的效果:文本框输入为空时显示输入的图标:不为空时显示清空的图标,此时点击清空图标能清空文本框内输入文字. 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnbl ...