HDUOJ----Super Jumping! Jumping! Jumping!
Super Jumping! Jumping! Jumping!
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5 Accepted Submission(s) : 1
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
for(i=;i<n;i++)
{
temp=;
for(j=;j<i;j++)
{
if(arr[i]>arr[j]&&dp[j]>temp)
temp=dp[j];
}
dp[i]=temp+arr[i];
}
上面的公式,运用的范围极为广泛....注意记下来!!
代码如下:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,i,j,temp;
while(cin>>n,n)
{
vector<int>arr(n,);
vector<int>dp(n,);
for(i=;i<n;i++)
{
cin>>arr[i];
}
int max=;
for(i=;i<n;i++)
{
temp=;
for(j=;j<i;j++)
{
if(arr[i]>arr[j]&&dp[j]>temp)
temp=dp[j];
}
dp[i]=temp+arr[i]; max=max>dp[i]?max:dp[i];
}
cout<<max<<endl;
}
return ;
}
HDUOJ----Super Jumping! Jumping! Jumping!的更多相关文章
- HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)
传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...
- E - Super Jumping! Jumping! Jumping!
/* Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popula ...
- Super Jumping! Jumping! Jumping!
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...
- DP专题训练之HDU 1087 Super Jumping!
Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...
- hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Super Jumping! Jumping! Jumping!——E
E. Super Jumping! Jumping! Jumping! Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO forma ...
- 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
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP)
C - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
随机推荐
- [Git] 写文章 史上最全文献检索、阅读及管理攻略
copy from : https://zhuanlan.zhihu.com/p/30605683 一.查文献 首先,我认为需要常备几个体量大.文献全的数据库,有针对性找哦!下面列出了一些适合所有专 ...
- 用java解析在OpenStreetMap上下载的地图数据(SAX版,适合比较大的xml文件)
java程序如下: package gao.map.preprocess; import java.io.BufferedWriter; import java.io.File; import jav ...
- <mvc:annotation-driven />做了什么
<mvc:annotation-driven /> 是一种简写形式,完全可以手动配置替代这种简写形式,简写形式可以让初学都快速应用默认配置方案.<mvc:annotation-dri ...
- java.net.URI 简介 文档 API
URI 简介 文档地址:http://tool.oschina.net/apidocs/apidoc?api=jdk-zh public final class java.net.URI extend ...
- mysql数据库查询优化
上两周一直想办法提高查询速度,取得一点效果,解决了部分问题,记下来以便将来自己查看. 由于公司没有专门的DBA,我自己对mysql数据库也不是很熟悉,而且这个JAVA开发的网络审计系统的管理系统,是经 ...
- 红米NOTE应用闪退(包括系统设置等各种界面)问题解决经历
关机状态下同时按减音量按钮和开机按钮,进入一个菜单,选择recovery(减音量键是移动,加音量键是确定),当出现一个倒地的机器人的时候,稍待片刻按开机键会出现双清以及刷机菜单.wipe data/f ...
- 在Win7上安装MySql5.2遇到Write configuration file的解决
机器从XP翻新到Win7后,原有的环境也被清除了,因此找了个时间重新安装MySql. 以前轻车熟路的过程,在最后一环却卡住了,出现Write configuration file 错误. 以前从来没有 ...
- spring mvc返回jsonp内容
代码如下: import com.alibaba.fastjson.JSONPObject; @RequestMapping(value = "/method1") @Respon ...
- POSIX 线程 – pthread_sigmask
http://www.cnblogs.com/qq78292959/archive/2012/04/05/2432985.html 概念 按照 POSIX, 异步 (外部) 信号发送到整个进程. 所有 ...
- INSTALL_FAILED_MISSING_SHARED_LIBRARY
target选项中要选择Google APIs.如图.