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 ------------------------------------------------ ...
随机推荐
- Xamarin开发综述
https://blog.csdn.net/qq_41647999/article/details/84844357 一. 前言这十来天对Xamarin的学习踩了很多的坑,说来也是一把心酸泪,下面为大 ...
- 使用cakewalk将工程速度与音频速度对齐(扒带参考)
题外话.cakewalk bandlab版免费 西贝柳斯打谱软件 fisrt版本 免费 (好像限制只能写4个声部) 1选中音频轨中的音频,按住alt+a调出audiosnap. 2点击 根据剪 ...
- stm32F1 DMA
DMA,全称是Direct Memory Access,中文意思为直接存储器访问 DMA可用于实现外设与存储器之间或者存储器与存储器之间数据传输的高效性 DMA请求映像 各通道的DMA1请求: 各通道 ...
- 2.Redis 入门介绍
A)入门概述: 1.是什么: Redis:REmote Dlctionary Server(远程字典服务器) 是完全开源免费的,用C语言编写的,遵循BSD协议,是一个高性能的(key/value) ...
- RabbitMQ中初始化ConnectionFactory常用设置属性
初始化ConnectionFactory 代码 ConnectionFactory factory = new ConnectionFactory(); factory.setHost(ip); fa ...
- MySQL详细知识点总结
1 Windows服务 -- 启动MySQL net start mysql -- 创建Windows服务 sc create mysql binPath= mysqld_bin_path(注意:等号 ...
- http上传txt文件
http通过post方式上传txt文件 可以参考 https://www.cnblogs.com/s0611163/p/4071210.html /// <summary> /// Htt ...
- MySQL操作规范总结
来源:静以致远√团团 用户权限管理创建用户命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password';说明:Username所创建的用户名hos ...
- ARP、Proxy ARP、Gratuitous ARP
Proxy ARP 什么是Proxy ARP? 一个主机A(通常是路由器)有意应答另一个主机B的ARP请求(ARP requests).主机A通过伪装其身份,承担起将分组路由到真实目的地的责任.代理A ...
- linux 基础11-例行性命令
1. 什么是例行性命令 1.1 linux工作排程的种类: linux例行性命令主要有两种: at:仅执行一次就从linux的任务中取消 cron:将持续例行性的工作下去 1.2 系统常见的例行性命令 ...