HDU 1087 最大递增子序列
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 56574 Accepted Submission(s): 26248
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.
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.
3 1 3 24 1 2 3 44 3 3 2 10
4103
【题意】
这个游戏可以由两个人或两个人以上玩。它由一个棋盘和一些棋子组成,所有的棋子都用一个正整数或“开始”或“结束”来标记。玩家从起点开始,最终必须跳到终点。在跳跃的过程中,玩家将访问路径中的棋子,但是每个人都必须从一个棋子跳到另一个更大的棋子(您可以假设起点是最小的,终点是最大的)。所有的玩家都不能倒退。一次跳跃可以从一个棋子跳到下一个棋子,也可以跨越许多棋子,甚至可以直接从起点到终点。当然在这种情况下你得到的是0。当且仅当一名运动员能根据他的跳跃方案得到一个更大的分数时,他就是赢家。注意,你的分数来自于你跳跃路径上棋子的价值总和。
我们需要根据给定的棋子列表输出最大值。
【代码】
#include<bits/stdc++.h>
using namespace std;
int sum[],a[];
int main(){
int i,n,mmax=,maxa=;
while(cin>>n && n){
memset(a,,sizeof(a));
for(i=; i<=n; i++){
cin>>a[i];
}
for(i=; i<=n; i++){
mmax = ;
for(int j=; j<i; j++)
if(a[j] < a[i])
mmax = max(sum[j],mmax);
sum[i] = mmax + a[i];
maxa = max(maxa,sum[i]);
}
cout<<maxa<<endl;
maxa = ;
}
return ;
}
HDU 1087 最大递增子序列的更多相关文章
- hdu 1087 最大递增子序列和
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #defin ...
- HDU 1087 最大上升子序列的和
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 1087 最大上升子序列的和(dp或线段树)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 1087 最大递增和
思路和LIS差不多,dp[i]为i结尾最大值 #include <iostream> #include <string> #include <cstring> #i ...
- HDU 1087 简单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! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- HDU 1257 最少拦截系统 最长递增子序列
HDU 1257 最少拦截系统 最长递增子序列 题意 这个题的意思是说给你\(n\)个数,让你找到他最长的并且递增的子序列\((LIS)\).这里和最长公共子序列一样\((LCS)\)一样,子序列只要 ...
- (最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087
http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit:1000MS ...
随机推荐
- 机器学习中的数学-强大的矩阵奇异值分解(SVD)及其应用
版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使用,但请注明出处,如果有问题,请联系wheeleast@gm ...
- 码云 VS首次提交代码报错:failed to push some refs to 'https://gitee.com/Liu_Cabbage/ASP.NET-MVC-QQ-Connect.git'
打开命令提示符: 执行合并命令: git pull --rebase origin master 最后总结: 1.多为第一次提交代码,本地和码云仓库不一致,README.md文件不在本地代码目录中 2 ...
- django中权限控制到按钮级别
权限控制到按钮级别 : 1.思路 : 由于每个按钮都能认为是一个权限,所以每个按钮都会有一个自己的路径,这些路径都在用户登录时保存在了session ...
- Python中正则匹配使用findall,捕获分组(xxx)和非捕获分组(?:xxx)的差异
转自:https://blog.csdn.net/qq_42739440/article/details/81117919 下面是我在用findall匹配字符串时遇到的一个坑,分享出来供大家跳坑. 例 ...
- PHP---反射--继续剖析
首先定义一个类 <?phpInterface trainning{ public function exec();}class mma implements trainning{ public ...
- FastDFS+Nginx+Module
1.安装libevent wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.g ...
- sync、fsync和fdatasync
转自 http://blog.csdn.net/todd911/article/details/11701847 传统的UNIX实现在内核中设有缓冲区高速缓存或页面高速缓存,大多数磁盘 I/O都通过缓 ...
- Codeforces 1272 A-E
Codeforces 1272 A-E A Three Friends 直接枚举所有情况,共\(3\times 3\times 3=27\)种. code #include<bits/stdc+ ...
- Ubuntu 14.04 tar 打包系统安装到新机器
制作Ubuntu14.04 的u启动盘,重启电脑进入要克隆的系统,打包整个根目录 su cd / tar -cvpzf /media/cdrom/backup.tar.gz / --exclude=/ ...
- loadrunner11安装
今天虚拟机里面装了下lr11,虚拟机版本是vm9.0,先在虚拟机里面装了windows2003,当然lr也是可以装在自己电脑上面的,但是最好是纯净的环境,由于我电脑东西比较多,所以我就装在虚拟机里面了 ...