HDU 1087 E - Super Jumping! Jumping! Jumping! DP
http://acm.hdu.edu.cn/showproblem.php?pid=1087
设dp[i]表示去到这个位置时的最大和值。(就是以第i个为结尾的时候的最大值)
那么只要扫描一遍dp数组,就能得到ans,因为最后一步可以无条件到达终点。
那么可以用O(n^2)转移,枚举每一个位置,其中要初始化dp值,dp[i] = a[i],意思就是到达第i个位置的时候,和值最小也是
a[i]把,因为无论如何也可以一步到达a[i]这个值。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = + ;
LL dp[maxn];
int n;
int a[maxn];
void work() {
for (int i = ; i <= n; ++i) {
cin >> a[i];
}
for (int i = ; i <= n; ++i) {
dp[i] = a[i];
for (int j = ; j < i; ++j) {
if (a[j] >= a[i]) continue;
dp[i] = max(dp[i], dp[j] + a[i]);
}
}
LL ans = -1e18L;
for (int i = ; i <= n; ++i) {
ans = max(dp[i], ans);
}
cout << ans << endl;
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
IOS;
while (cin >> n && n) work();
return ;
}
HDU 1087 E - Super Jumping! Jumping! Jumping! DP的更多相关文章
- 【HDU - 1087 】Super Jumping! Jumping! Jumping! (简单dp)
Super Jumping! Jumping! Jumping! 搬中文ing Descriptions: wsw成功的在zzq的帮助下获得了与小姐姐约会的机会,同时也不用担心wls会发现了,可是如何 ...
- HDU 1087:Super Jumping! Jumping! Jumping!(LIS)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- hdu 1087 最长上升序列和 dp
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- (最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087
http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit:1000MS ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1069&&HDU 1087 (DP 最长序列之和)
H - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- 怒刷DP之 HDU 1087
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
随机推荐
- POJ2657Comfort(扩展欧几里得基础)
A game-board consists of N fields placed around a circle. Fields are successively numbered from1 to ...
- ACM学习历程—HDU 5326 Work(树形递推)
Problem Description It’s an interesting experience to move from ICPC to work, end my college life an ...
- python爬虫知识点总结(八)Selenium库详解
官方学习文档:http://selenium-python.readthedocs.io/api.html 一.什么是Selenium? 答:自动化测试工具,支持多种浏览器.用来驱动浏览器,发出指令让 ...
- U盘安装CentOS的坑
坑一:U盘安装盘配置的路径错误 采用UltraISO制作的CentOS7的安装光盘,但是在实体机安装的时候,发生了一些奇怪的失败,比如 dracut-initqueue timeout等,后来在网上搜 ...
- Adobe Flash Player 27 on Fedora 27/26, CentOS/RHEL 7.4/6.9
This is guide, howto install Adobe Flash Player Plugin version 27 (32-bit and 64-bit) with YUM/DNF o ...
- 【win10激活问题】 从【win10专业工作站版】转为 数字许可证的【win10专业版】
今天安装了 win10 1903 (10.0.18362 暂缺 Build 18362) 安装时 选的 是[win10 专业工作站版] 却无法激活, (因为当初是从win7升级上win10的,只有关联 ...
- eclipse中jquery.js文件有错误提示…
eclipse中jquery.js文件有错误提示的解决办法 2013-04-06 19:18 浏览次数:382 由于jquery.js文件进行了压缩,压缩之后的语法eclipse无法完全识别,所以有错 ...
- Spring3注解零配置
我们在以前学习 Spring 的时候,其所有的配置信息都写在 applicationContext.xml 里,大致示例如下: java代码: 查看复制到剪贴板打印 OracleDriver& ...
- centos6.5安装FTP服务器
1.检测是否安装了FTP rpm -q vsftpd 2.安装ftp yum install vsftpd 3.完成ftp安装后,将 /etc/vsftpd/user_list 和 /etc/vsft ...
- phpstudy配置php7.1.11
php7.1.11下载地址 http://windows.php.net/download/ 下载之后,解压. 重名的为php-7.1.11-nts 移动到phpStudy的php目录下 然后重启ph ...