HDU 1087 Super Jumping! Jumping! Jumping! ——(LIS变形)
和之前那个长方体最大高度是换汤不换药的题目。每次找之前最大的一个能接的接上即可。代码如下:
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = + ; int a[N];
int dp[N]; int main()
{
int n;
while(scanf("%d",&n) == && n)
{
for(int i=;i<=n;i++) scanf("%d",a+i);
memset(dp,,sizeof dp);
for(int i=;i<=n;i++)
{
int pos = -;
for(int j=;j<i;j++)
{
if(a[j] >= a[i]) continue;
if(pos == -) pos = j;
else if(dp[pos] < dp[j]) pos = j;
}
if(pos == -) dp[i] = a[i];
else dp[i] = dp[pos] + a[i];
}
printf("%d\n",*max_element(dp+,dp++n));
}
return ;
}
HDU 1087 Super Jumping! Jumping! Jumping! ——(LIS变形)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- 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! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP+LIS)
题意:给定一个长度为n的序列,让你求一个和最大递增序列. 析:一看,是不是很像LIS啊,这基本就是一样的,只不过改一下而已,d(i)表示前i个数中,最大的和并且是递增的, 如果 d(j) + a[i] ...
- HDU 1087 Super Jumping! Jumping! Jumping! (LIS的最大和)
题意: 给定n个数的序列, 找出最长上升子序列和. 分析: #include<cstdio> #include<iostream> #include<queue> ...
- 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!
Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
随机推荐
- CSS3实现瀑布流布局
讲干货,不啰嗦,瀑布流布局是种常见的布局方式,常用于图片相关的样式展示,通过CSS3的多列(Multi-column)属性,可以简单的实现类似效果. 具体步骤: 1.设置外部容器多列列数(column ...
- mysql控制台常用命令
登录: D:\seegot\mysql5.5.36\bin> mysql -uroot -proot Welcome to the MySQL monitor. Commands end wit ...
- Java架构师告诉你Spring IoC有什么好处呢
前言: 这个问题也一直困惑我很久,毕竟其他语言没有IOC也活的很好. 但是Spring在当时能够一统江湖,跟IOC真的有很大的关系. 在没有IOC的时代,New代表一切,女朋友都是可以New出来的. ...
- iptables网络防火墙和SNAT原理实战
网络防火墙 iptables/netfilter网络防火墙: (1) 充当网关 (2) 使用filter表的FORWARD链 注意的问题: (1) 请求-响应报文均会经由FORWARD链,要注意规则的 ...
- RHEL7启动到命令模式
打开/etc/inittab 文件会看到以下信息 从中知道想要启动后就进入完整的多用户文本模式(命令行模式) 以root权限执行: ln -sf /lib/systemd/system/multi-u ...
- centos7误删yum源的解决办法 ( -bash: yum: command not found)
这里以安装阿里的yum源为例: 1.查看自己的centos版本 cat /etc/redhat-release 2.进入阿里云源站地址:http://mirrors.aliyun.com/centos ...
- Go语言中的defer
可以用作一些资源的释放. 1.在一个函数内的defer执行顺序是先写的后执行,后写的先执行(遵循栈结构) func DeferTest1(){ defer fmt.Println("我是 d ...
- Gradle 的使用
gradle 工具类似于maven工具,但是gradle 减少了maven中的那种使用xml 中大量的配置文件来下载依赖的jar包.而gradle大大简化了,能够很快速的添加依赖.具体关于gradle ...
- openpose-opencv 的body数据多人体姿态估计
介绍 opencv除了支持常用的物体检测模型和分类模型之外,还支持openpose模型,同样是线下训练和线上调用.这里不做特别多的介绍,先把源代码和数据放出来- 实验模型获取地址:https://gi ...
- CSS3媒体查询实例
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...