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 ------------------------------------------------ ...
随机推荐
- jvm垃圾回收器介绍
上篇文章中我们讨论了jvm的内存区域,这篇文章我们来讨论针对的内存区域的垃圾回收机制. 其实针对垃圾回收我们通常考虑三个问题:1.哪些内存需要回收?2.什么时候回收?3.如何回收?下面我们针对这三个问 ...
- Rider开发开发.NET Framework 4.5项目遇到的一些问题
使用rdier自带resharper功能,蛮爽的但是编译旧的项目时一直报错:Invalid option 'portable' for /debug; must be full or pdbonly' ...
- siamese跟踪论文思考
转载自:https://zhuanlan.zhihu.com/p/34222060 通过作者在专栏里面放的几张响应图我们可以看到:SiamFC并不能区分不同的物体,图片上所有具有语义信息的物体都会得到 ...
- TCP的三次握手与四次挥手笔记
TCP的三次握手与四次挥手笔记 TCP Flags URG: 紧急指针标志 ACK:确认序号标志 PSH:push标志 RST:重置连接标志 SYN:同步序号,用于建立连接过程 FIN: finish ...
- vue 钩子函数的初接触
vue-router的路由钩子函数: 第一种:全局钩子函数. router.beforeEach((to, from, next) => { console.log('beforeEach') ...
- 自适应高度文本框 react contenteditable
import React, { Component } from 'react'; import PropTypes from 'prop-types'; const reduceTargetKeys ...
- 批量更新sql
跨库 批量更新 UPDATE a.table_1upINNER JOIN ( SELECT user_id, user_org_company_id, FROM b.table_2) AS tmp O ...
- 关于在window8上使用ssh命令的记录
1.开启虚拟机以及git bash窗口,准备连接 2.在虚拟机中输入ifconfig -a查看虚拟机ip 从图中找到ip为 : inet 地址:192.168.78.133 3.输入命令: ssh r ...
- 网络OSI 7层模型
OSI 的英文全程为Open Systems Interconnection ,中文全程为开放系统互联参考模型.是一个逻辑上的定义.主要用途使通信和计算系统自由互联,而不依赖其他架构或技.主要目标就是 ...
- nginx精准反向代理
1,完全反向代理,将请求10.130.111.110服务器的请求全部转发到10.130.111.111服务器 location / { proxy_pass http://10.130.111.111 ...