和之前那个长方体最大高度是换汤不换药的题目。每次找之前最大的一个能接的接上即可。代码如下:

 #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变形)的更多相关文章

  1. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...

  2. HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...

  3. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...

  4. HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *

    Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64 ...

  5. HDU 1087 Super Jumping! Jumping! Jumping! (DP+LIS)

    题意:给定一个长度为n的序列,让你求一个和最大递增序列. 析:一看,是不是很像LIS啊,这基本就是一样的,只不过改一下而已,d(i)表示前i个数中,最大的和并且是递增的, 如果 d(j) + a[i] ...

  6. HDU 1087 Super Jumping! Jumping! Jumping! (LIS的最大和)

    题意: 给定n个数的序列, 找出最长上升子序列和. 分析: #include<cstdio> #include<iostream> #include<queue> ...

  7. hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  8. 题解报告:hdu 1087 Super Jumping! Jumping! Jumping!

    Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...

  9. hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...

随机推荐

  1. Nginx Too many open files

    2019/07/25 08:31:31 [crit] 15929#15929: accept4() failed (24: Too many open files) 2019/07/25 08:31: ...

  2. sql 给相同属性的数据排序

    UPDATE b SET OrderIndex = a.OrderIndex FROM ( SELECT RTRIM(ROW_NUMBER() OVER ( PARTITION BY [ItemID] ...

  3. LeetCode 【2】 Reverse Integer --007

    六月箴言 万物之中,希望最美:最美之物,永不凋零.—— 斯蒂芬·金 第二周算法记录 007 -- Reverse Integer (整数反转) 题干英文版: Given a 32-bit signed ...

  4. pcntl

    <?php function my_pcntl_wait($childProcessCode){ $pid = pcntl_fork(); if($pid>0){ pcntl_wait($ ...

  5. 阿里高级架构师教你如何使用Spring Cloud Ribbon重试请求

    在微服务调用中,一些微服务圈可能调用失败,通过再次调用以达到系统稳定性效果,本文展示如何使用Ribbon和Spring Retry进行请求再次重试调用. 在Spring Cloud中,使用load b ...

  6. 08 Windows编程——画图

    源码 #include<Windows.h> #include<tchar.h> #include<stdio.h> #define NUM 1000 LRESUL ...

  7. 机器学习(十)—聚类算法(KNN、Kmeans、密度聚类、层次聚类)

    聚类算法 任务:将数据集中的样本划分成若干个通常不相交的子集,对特征空间的一种划分. 性能度量:类内相似度高,类间相似度低.两大类:1.有参考标签,外部指标:2.无参照,内部指标. 距离计算:非负性, ...

  8. [Python] Codecombat 攻略 Sarven 沙漠 (1-43关)截止至36关

    首页:https://cn.codecombat.com/play语言:Python 第二界面:Sarven沙漠(43关)时间:4-11小时内容:算术运算,计数器,while循环,break(跳出循环 ...

  9. xfs 文件系统

    centos7.0开始默认文件系统是xfs,centos6是ext4,centos5是ext3 ext3和ext4的最大区别在于,ext3在fsck时需要耗费大量时间(文件越多,时间越长),而ext4 ...

  10. DevExpress WPF v19.2图表图形控件功能增强?速速种草

    通过DevExpress WPF Controls,你能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案. 无论是Office办公软件的衍 ...