HDU 1087 最大上升子序列的和
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32134 Accepted Submission(s): 14467
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.
0
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n;
int a[];
int ans[];
int exm;
int main()
{
while(scanf("%d",&n)!=EOF)
{
if(n==)
break;
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
ans[i]=a[i];
}
int maxlen=-;
for(int i=;i<=n;i++)
{
int maxn=;
for(int j=;j<i;j++)
{
if(a[j]<a[i]&&maxn<ans[j])
{
maxn=ans[j];
}
}
ans[i]=maxn+a[i];
if(ans[i]>maxlen)
{
maxlen=ans[i];
exm=i;
}
}
cout<<maxlen<<endl;
}
return ;
}
HDU 1087 最大上升子序列的和的更多相关文章
- hdu 1087 最大上升子序列的和(dp或线段树)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 1087 最大递增子序列和
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #defin ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- (最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087
http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit:1000MS ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- HDU 1069&&HDU 1087 (DP 最长序列之和)
H - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1231 最大连续子序列 --- 入门DP
HDU 1231 题目大意以及解题思路见: HDU 1003题解,此题和HDU 1003只是记录的信息不同,处理完全相同. /* HDU 1231 最大连续子序列 --- 入门DP */ #inclu ...
随机推荐
- GNU 关闭 MMU 和 Icache 和 Dcache
1. cp15 寄存器 disable Icache 和 Dcache . disable_MMU: MCR p15,0,r0,c7,c7,0 MRC p15,0,r0,c1,c0,0 bic r ...
- PHP CodeIgniter框架实现读写分离
一.目标 当前服务器只做了主从,未配置读写分离,读写分离的功能就只有交给程序来实现,本文主要谈谈Codeigniter怎么实现读写分离,并且需要满足以下两点: 1.读写分离对开发应该透明. 网上有方案 ...
- mysql悲观锁与乐观锁
简介 数据库管理系统(DBMS)中的并发控制的任务是确保在多个事务同时存取数据库中同一数据时不破坏事务的隔离性和统一性以及数据库的统一性. 用途 乐观锁和悲观锁是并发控制主要采用的技术手段.无论是悲观 ...
- 【php】关于trim,rtrim,ltrim,substr 的字符串切割导致 json,_encode无法 识别数据的问题
示例 <?php $a = rtrim('南宁 .',' .'); echo $a; //输出 南�� echo json_encode($a); //输出空白 $b = ['name'=> ...
- php扩展开发-面向对象
在zval变量里IS_OBJECT类型使用zend_object_value来保存变量的,我们看一下他的具体结果. typedef struct _zend_object_value { zend_o ...
- IAR 编译时找不到头文件的解决方法
Fatal Error[Pe1696]: cannot open source file "x.h" 那是因为头文件路径没有找对 到报错的.c源文件 选中右键 选择options ...
- git重新下载项目
file-new-project from version control - git 修改网址为需要的网址
- 关于C、内存、栈的一些杂谈
c的程序要手动管理内存的,所有的数据(结构)都可以分为两种存储方式,连续存储,顾名思义申请一片连续的内存以供使用(数组.结构体.共用体.栈.队列):非连续存储,顾名思义断断续续的的存储,那有一点这有一 ...
- gprof使用介绍 (gcc -pg) [转]
原文出处: http://blog.csdn.net/unbutun/article/details/6609498 linux服务端编程,性能总是不可避免要思考的问题. 而单机(严格的说是单核)单线 ...
- 云计算之路-阿里云上:OCS问题的进展以及11:30-11:50遇到的问题
(上图是今天出问题期间Web服务器性能监控图,紫色表示的是Request Execution Time) 昨天我们发布了一篇博客分享了我们这两天遇到的OCS(开放缓存服务)问题,详见云计算之路-阿里云 ...