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 ...
随机推荐
- MySQL启动相关知识
使用mysqld和mysqld_safe启动的区别 直接运行mysqld程序来启动MySQL服务的方法很少见,mysqld_safe脚本[注意:mysqld_safe只是一个脚本]会在启动MySQL服 ...
- php添加gd
一 GD简介: php处理图形的扩展库,提供了一系列用来处理图片的API.如果开发过程中发现有页面验证码不能显示,则要考虑检查phpinfo(),是否支持GD库. 二 思路: 网上发现添加GD库的方法 ...
- anyremote源码分析
XTest 鼠标移动事件. XTestFakeMotionEvent 关于XTest的编程. http://lilydjwg.is-programmer.com/2011/9/21/using-x ...
- junit 单元测试 - 参数化测试
junit4.x版本需要引入如下jar包: hamcrest-core-1.3.jar junit-4.12-beta-3.jar 新建一个计算器类,如下: package com.pt; publi ...
- 判断是ios还是android
//判断是ios还是androidvar system;var ua = navigator.userAgent.toLowerCase(); if (/iphone|ipad|ipod/.test( ...
- TextureView+SurfaceTexture+OpenGL ES来播放视频(三)
引自:http://www.jianshu.com/p/291ff6ddc164 做好的Demo截图 opengl-video 前言 讲了这么多,可能有人要问了,播放视频用个android封装的Vid ...
- 一个经典的PHP验证码类分享
我们通过PHP的GD库图像处理内容,设计一个验证码类Vcode.将该类声明在文件vcode.class.php中,并通过面向对象的特性将一些实现 的细节封装在该类中.只要在创建对象时,为构造方法提供三 ...
- World Finals 2003 UVA - 1025 A Spy in the Metro(动态规划)
分析:时间是一个天然的序,这个题目中应该决策的只有时间和车站,使用dp[i][j]表示到达i时间,j车站在地上已经等待的最小时间,决策方式有三种,第一种:等待一秒钟转移到dp[i+1][j]的状态,代 ...
- cocos2d-js 显示帧序列图中的一帧
1.flashCC中打开库,在一个元件中右键->Generate Sprite Sheet...设置如下: 2.点Export后得到playerWalk.png和playerWalk.plist ...
- oracle xe client 如何设置 tnsnames.ora(解决无法使用pl/sql developer的问题)
10.2版本xe的服务器和客户端安装都很方便,由于xe的服务器只允许建立一个实例,实例名字会直接默认为xe,客户端默认安装在C:\XEClient目录下,使用sqlplus连接服务器: sqlplus ...