Super Jumping! Jumping! Jumping!---hdu1087(动态规划)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087
题意就是给你n个数,找出某个序列的最大和,这个序列满足依次增大的规则;
哎,这个题之前做过,但是一点印象都没有但是自己写出来了,估计当时写的时候也不知道为什么这样写吧,事实证明,题做多了自然就懂了;
我是拿做上升子序列的想法来做的。。。
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 1100
#define INF 0xfffffff
int main()
{
int n, a[N], dp[N], Max;
while(scanf("%d", &n), n)
{
memset(a, , sizeof(a));
memset(dp, , sizeof(dp));
for(int i=; i<=n; i++)
{
scanf("%d", &a[i]);
}
Max = ;
for(int i=; i<=n; i++)
{
dp[i] = a[i];
for(int j=; j<=i; j++)
{
if(a[i]>a[j])
dp[i] = max(dp[i], dp[j]+a[i]);
}
Max = max(Max, dp[i]);
}
printf("%d\n", Max);
}
return ;
}
Super Jumping! Jumping! Jumping!---hdu1087(动态规划)的更多相关文章
- HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)
传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...
- UVA 10269 Super Mario,最短路+动态规划
这个题目我昨晚看到的,没什么思路,因为马里奥有boot加速器,只要中间没有城堡,即可不耗时间和脚力,瞬间移动不超过L距离,遇见城堡就要停下来,当然不能该使用超过K次...我纠结了很久,最终觉得还是只能 ...
- HDU1087 - Super Jumping! Jumping! Jumping!【动态规划】
zh成功的在他人的帮助下获得了与小姐姐约会的机会,同时也不用担心被非"川大"的女票发现了,可是如何选择和哪些小姐姐约会呢?zh希望自己可以循序渐进,同时希望挑战自己的极限,我们假定 ...
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
Super Jumping! Jumping! Jumping!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- 解题报告 HDU1087 Super Jumping! Jumping! Jumping!
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- HDU1087:Super Jumping! Jumping! Jumping!(DP)
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 Super Jumping! Jumping! Jumping! Time Limit: 200 ...
- HDU1087 Super Jumping! Jumping! Jumping! 最大连续递增子段
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- matplotlib之极坐标系的极径网格线(rgrids)的显示刻度
matplotlib之极坐标系的极径网格线(rgrids)的显示刻度 #!/usr/bin/env python3 #-*- coding:utf-8 -*- #################### ...
- python-list.sort && lambda
dictionary是一个有元组组成的list,变量名有点歧义,这里是想表达 由元组组成的list哈. 之所以用dictionary是因为模拟的将字典转换成list. 将list进行排序,而根据lam ...
- 解决 Netbeans Ant: taskdef class org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs cannot be found
你在用Netbeans(实际上是Ant)Clean and Build你的项目生成可执行文件(例如Windows下的exe文件)时候遇到报错 或者遇到这样的报错: The libs.CopyLibs. ...
- Cannot change version of project facet Dynamic Web Module to 3.0 requires Java 1.6 or newer 解决方案
Eclipse Maven 开发一个 jee 项目时,编译时遇到以下错误:Description Resource Path Location TypeDynamic Web Module 3.0 r ...
- vSphereClient向ESXi主机分配许可证
ESXi服务器需要使用VMwarevSphereClient进行管理(7.0+版本可以通过浏览器进行管理)在VMware vSphere client可以方便的创建.管理虚拟机,并分配相应的资源.要能 ...
- Vector类与Enumeration接口
Vector类用于保存一组对象,由于java不支持动态数组,Vector可以用于实现跟动态数组差不多的功能.如果要将一组对象存放在某种数据结构中,但是不能确定对象的个数时,Vector是一个不错的选择 ...
- LigerTree的使用
效果图: 页面: <div id="divs" style="width: 310px; overflow-x: hidden; overflow-y: hidde ...
- 路由器port触发与转发---Port Forwarding & Port Triggering
What is Port Triggering? If you have not read my explanation of port forwarding do so now. You can f ...
- Python中xlrd和xlwt模块使用方法 (python对excel文件的操作)
本文主要介绍可操作excel文件的xlrd.xlwt模块.其中xlrd模块实现对excel文件内容读取,xlwt模块实现对excel文件的写入. 安装xlrd和xlwt模块 xlrd和xlwt模块不是 ...
- TypeScript 接口(三)
TypeScript的核心原则之一是对值所具有的结构进行类型检查. 接口初始: interface objProperty { name: string } function printName(na ...