hdu 1087 最长上升序列和 dp
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 56910 Accepted Submission(s): 26385
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.
#include<iostream>
#include<string.h>
using namespace std;
int a[],dp[];
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
int n;
while(cin>>n&&n!=)
{
for(int i=;i<n;i++)
cin>>a[i];
memset(dp,,sizeof(dp));
dp[]=a[];
for(int i=;i<n;i++)
{
for(int j=;j<i;j++)
{
if(a[i]>a[j])
dp[i]=max(dp[i],dp[j]+a[i]);
}
dp[i]=max(dp[i],a[i]); }
int ans=dp[];
for(int i=;i<n;i++)
ans=max(ans,dp[i]);
cout<<ans<<endl;
}
return ;
}
hdu 1087 最长上升序列和 dp的更多相关文章
- XHXJ's LIS HDU - 4352 最长递增序列&数位dp
代码+题解: 1 //题意: 2 //输出在区间[li,ri]中有多少个数是满足这个要求的:这个数的最长递增序列长度等于k 3 //注意是最长序列,可不是子串.子序列是不用紧挨着的 4 // 5 // ...
- FatMouse's Speed HDU - 1160 最长上升序列, 线性DP
#include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> usi ...
- (LIS)最长上升序列(DP+二分优化)
求一个数列的最长上升序列 动态规划法:O(n^2) //DP int LIS(int a[], int n) { int DP[n]; int Cnt=-1; memset(DP, 0, sizeof ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- HDU 1087 最长不下降子序列 LIS DP
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...
- HDU 1087 E - Super Jumping! Jumping! Jumping! DP
http://acm.hdu.edu.cn/showproblem.php?pid=1087 设dp[i]表示去到这个位置时的最大和值.(就是以第i个为结尾的时候的最大值) 那么只要扫描一遍dp数组, ...
- HDU 1087 Super Jumping! Jumping! Jumping!【DP】
解题思路:题目的大意是给出一列数,求这列数里面最长递增数列的和 dp[i]表示到达地点i的最大值,那么是如何达到i的呢,则我们可以考虑没有限制条件时候的跳跃,即可以从第1,2,3,---,i-1个地点 ...
- HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- 083、Java数组之方法返回数组
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public ...
- 小程序canvas 变换
var ctx = wx.createCanvasContext('base'); var centerX = 375/ 2; var centerY = 200; var rotate = 90; ...
- Eclipse创建一个动态maven项目详细步骤
新建maven项目,new一个Dynamic Web Project 项目 输入完项目名直接finish 配maven,右键项目configure,选择Convert to Plug-in Proje ...
- 实训41 S7通信 单向连接 基于DP网络通信
连接的基本概念? 连接是指两个通信伙伴之间执行通信服务建立的逻辑链路,而不是指两个站之间用物理媒体(例如电缆)实现的连接. 连接相当于 通信伙伴之间 一条虚拟的"专线". 一条物理 ...
- 对S7通信的连接的理解以及对比CAN通信协议来理解PLC通讯
对S7通信的连接的理解以及对比CAN通信协议来理解PLC通讯. 对功能块 SFB12 和 SFB13 的R_ID参数的理解 ? 对于同一个数据包.发送方与接收方的R_ID应该相同. 用下图解释 双向连 ...
- Ubuntu安装Orcale
Linux_Ubuntu安装oracle总结 ---------转自 https://www.2cto.com/database/201305/215338.html 话说我花了一晚上才在ubuntu ...
- LOJ #10002. 喷水装置
题目 裸的贪心. 基本思想见图: Code: #include<iostream> #include<cstdio> #include<cstring> #incl ...
- mysql DDL语言
- JAVA String类常用方法
一.String类String类在java.lang包中,java使用String类创建一个字符串变量,字符串变量属于对象.java把String类声明的final类,不能有类.String类对象创建 ...
- Problem C Updating a Dictionary
Problem C Updating a Dictionary In this problem, a dictionary is collection of key-value pairs, ...