HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1087
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 47055 Accepted Submission(s): 21755

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<cstring>
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==)
break;
int a[n];
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int dp[n];
dp[]=a[];
for(int i=;i<n;i++)
{
int max_v=;
for(int j=;j<i;j++)
{
if(a[j]<a[i])
{
if(max_v<dp[j])
{
max_v=dp[j];
}
}
}
dp[i]=max_v+a[i];
}
int max_v=dp[];
for(int i=;i<n;i++)
{
if(max_v<dp[i])
{
max_v=dp[i];
}
}
printf("%d\n",max_v);
}
return ;
}
回来更新一下:
今天训练赛又遇到了这个题目
贴一下代码(比一开始精简了点,因为理解了)
#include<bits/stdc++.h>
using namespace std;
#define INF 99999
int main()
{
//最大递增子序列和
int n;
while(cin>>n,n)
{
int a[n];
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int dp[n];
memset(dp,,sizeof(dp));
dp[]=a[];
int ans=;
for(int i=;i<n;i++)
{
int maxx=;
for(int j=;j<i;j++)
{
if(a[j]<a[i])
{
maxx=max(dp[j],maxx);
}
}
dp[i]=maxx+a[i];
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
}
return ;
}
HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- 题解报告:hdu 1087 Super Jumping! Jumping! Jumping!
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...
- HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)
传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...
- 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! 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP)
C - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
随机推荐
- 高级功能:很有用的javascript自定义事件
之前写了篇文章<原生javascript实现类似jquery on方法的行为监听>比较浅显,能够简单的使用场景. 这里的自定义事件指的是区别javascript默认的与DOM交互的事件,比 ...
- spring代理例子
---------------------------------------------------------- 先来看一下目录结构 显然service里面有两个java文件,UserDao是接口 ...
- LAMP创建
httpd yum install httpd -y systemctl status httpd systemctl start httpd systemctl stop firewalld Mar ...
- 多表批量导出txt及打压缩包下载
在一些特殊的业务系统中,有些客户查看报表数据时不需要在浏览器上逐一查看,需要在页面端选择要查看的报表名称(可多选),选择条件,然后将所选中的报表批量导出到txt文件中并且要把批量导出的结果文件打 ...
- Android应用程序启动过程(二)分析
本文依据Android6.0源码,从点击Launcher图标,直至解析到MainActivity#OnCreate()被调用. Launcher简析 Launcher也是个应用程序,不过是个特殊的应用 ...
- linux yum 安装wget、gcc、ifconfig、vim、setup
安装wgetyum -y install wget安装gcc c语言编译器yum -y install gcc安装ifconfigyum -y install net-tools.x86_64安装vi ...
- 我的blog第一天
今天是2017年6月13号,一个很平凡的日子,但是对我来说意义非凡.这是我开通博客的第一天,这是我写的第一篇文章. 先自我介绍一下,本人邢卜,河北石家庄人,生于89年6月,说到这我马上就要过生日了!嘿 ...
- 6.HTML速查模块
1.HTML 基本文档 <!DOCTYPE html> <html> <head> <title>文档标题</title> </hea ...
- statsmodels中的summary解读(以linear regression模型为例)
https://datatofish.com/statsmodels-linear-regression/ https://blog.datarobot.com/ordinary-least-squa ...
- 将虚拟网络连接到 ExpressRoute 线路
本文通过使用 Resource Manager 部署模型和 Azure 门户,帮助将虚拟网络 (VNets) 链接到 Azure ExpressRoute 线路. 虚拟网络可以在同一个订阅中,也可以属 ...