Super Jumping! Jumping! Jumping! 基础DP
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31490 Accepted Submission(s): 14146
a kind of chess game called “Super Jumping! 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.
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.
4 1 2 3 4
4 3 3 2 1
0
10
3
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = ;
int a[maxn];
long long dp[maxn];
void solve(){
int n;
while(scanf("%d",&n)!=EOF&&n){
for(int i = ; i<=n; i++) scanf("%d",&a[i]);
memset(dp,,sizeof(dp));
long long ans = ;
for(int i = ; i<=n; i++){
dp[i] = a[i];
for(int j = ; j<=i; j++){
if(a[i]>a[j]){
dp[i] = max(dp[i],dp[j]+a[i]);
}
}
ans = max(ans,dp[i]);
}
printf("%I64d\n",ans);
}
}
int main()
{
solve();
return ;
}
Super Jumping! Jumping! Jumping! 基础DP的更多相关文章
- 「kuangbin带你飞」专题十二 基础DP
layout: post title: 「kuangbin带你飞」专题十二 基础DP author: "luowentaoaa" catalog: true tags: mathj ...
- 基础dp
队友的建议,让我去学一学kuangbin的基础dp,在这里小小的整理总结一下吧. 首先我感觉自己还远远不够称为一个dp选手,一是这些题目还远不够,二是定义状态的经验不足.不过这些题目让我在一定程度上加 ...
- 基础DP(初级版)
本文主要内容为基础DP,内容来源为<算法导论>,总结不易,转载请注明出处. 后续会更新出kuanbin关于基础DP的题目...... 动态规划: 动态规划用于子问题重叠的情况,即不同的子问 ...
- hdu 5586 Sum 基础dp
Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Desc ...
- hdu 4055 Number String (基础dp)
Number String Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 训练指南 UVA - 10917(最短路Dijkstra + 基础DP)
layout: post title: 训练指南 UVA - 10917(最短路Dijkstra + 基础DP) author: "luowentaoaa" catalog: tr ...
- 训练指南 UVA - 11324(双连通分量 + 缩点+ 基础DP)
layout: post title: 训练指南 UVA - 11324(双连通分量 + 缩点+ 基础DP) author: "luowentaoaa" catalog: true ...
- M - 基础DP
M - 基础DP Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descriptio ...
- lightoj1004【基础DP】
从低端到顶端求个最大值: 思路: 基础DP,递推 #include<cstdio> #include<queue> #include<map> #include&l ...
随机推荐
- MyEclipse的Expressions没有结果的解决办法
之前我的Expressions在Value这一列什么都不显示,就连简单的1+2结果3都不显示出来. 然后我咬咬牙把它卸载了,然后重装就好了,我也不清楚是什么原因. 1.之前我安装的目录是"C ...
- JSP内置对象--4种属性范围 (pageContext,request,session,application)
pageContext: javax.servlet.jsp.JspContext抽象类的父类JspContext 中有以下方法. request:javax.servlet.http.的接口Http ...
- 20150627分享iOS开发笔记
util是工具的意思:Ad Hoc是特别的,临时的意思;validate是验证的意思: 打包 苹果的键盘真好使 6和6 plus真机测试报错:No architectures to compile f ...
- 使用WMware新建linux虚拟机
使用WMware安装linux虚拟机的时候很多人搞不清楚使用什么适配器. 平时也看到很多误人子弟的观点,这里用事实说话. VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络 ...
- prototype小解
prototype由来 在理解prototype前,首先得理解js面向对象编程的私有变量.私有函数,静态变量.静态函数,以及实例变量,实例函数 私有变量,私有函数 函数内部通过var定义的变量 fun ...
- 判断是ios还是android
//判断是ios还是androidvar system;var ua = navigator.userAgent.toLowerCase(); if (/iphone|ipad|ipod/.test( ...
- JPA 系列教程8-双向一对一共享主键
双向一对一共享主键的ddl语句 CREATE TABLE `t_person` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(25 ...
- 利用Fiddler抓取手机APP数据包
Fiddler是一个调试代理,下载地址http://www.telerik.com/download/fiddler 下载安装运行后,查出运行机器的IP,手机连接同一网域内的WIFI,手机WIFI连接 ...
- 小蚂蚁搬家<贪心>
题意: 由于预知未来可能会下雨,所以小蚂蚁决定搬家.它需要将它的所有物品都搬到新家,新家的体积为V,小蚂蚁有N件物品需要搬,每件物品的体积为Ai,但他发现:每件物品需要新家剩余体积大于等于Bi才能使它 ...
- NSUserDefault -- synchronize 浅析
NSUserDefault的使用比较简单:NSUserDefaults *mySettingData = [NSUserDefaults standardUserDefaults]; 创建NSUse ...