hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)

题意:
求解最大递增子序列。
例如:3 1 3 2
输入 3 个数 1 3 2
则递增子序列有 {1} {3} {2} {1 3} {1 2} ,故输出子序列的最大和 4
解题思路:
x[n](n个数) 数组存储 输入的数据
dp[i] 用来记录 前 i+1 {数据从下标为0开始存储}个数的 最大结果
遍历dp[] 找到最大值即可。
因 G20 网站暂停提交
明天测试代码。
2016.08.27 代码提交成功!
代码如下:
#include<bits/stdc++.h>
using namespace std;
int x[];
int dp[];
int main()
{
int n;
while(scanf("%d",&n)!=EOF&&n)
{
int i,j,maxx=;
for(i=; i<n; i++)
{
scanf("%d",&x[i]);
}
memset(dp,,sizeof(dp));
dp[]=x[];
for(i=; i<n; i++)
{
for(j=; j<i; j++)
{
if(x[i]>x[j])
dp[i]=max(dp[j],dp[j]+x[i]);
}
dp[i]=max(dp[i],x[i]);
maxx=max(dp[i],maxx);
}
printf("%d\n",maxx);
}
return ;
}
hdu 1087 Super Jumping! Jumping! Jumping!(动态规划)的更多相关文章
- HDU 1087 Super Jumping! Jumping! Jumping
HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...
- 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!(求LSI序列元素的和,改一下LIS转移方程)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 20 ...
- 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)
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 ...
- 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....(动态规划之最大递增子序列和)
Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- swift 判断输入的字符串是否为数字
// 判断输入的字符串是否为数字,不含其它字符 func isPurnInt(string: String) -> Bool { let scan: Scanner = Scanner(stri ...
- 记2012-2013年一路的Windows Phone历程
昨天和秦春林同学小聚一次,不厌其烦的唠叨各种认识了许多年的纪念,感觉他仍然保持着那份对技术的追求和梦想,而我却已经变得逐利,每个人享受幸福的方式不一样,因此追逐幸福的过程也就是没有办法一样了,你无法知 ...
- Apache Options Indexes FollowSymLinks详解
禁止显示Apache目录列表-Indexes FollowSymLinks如何修改目录的配置以禁止显示 Apache 目录列表.缺省情况下如果你在浏览器输入地址: http://localhost:8 ...
- How to configure SRTM elevations in WorldWind WMS
In this thread I will try to explain how to serve SRTM elevations using NASA WorldWind WMS. ! Import ...
- 求时间差的sql语句。 比如如下数据
msisdn createtime closetime138 2011-5-17 15:30:00:000 2011-5-17 15:30:00:530138 2011-5-17 15:40:00:0 ...
- win7(X64)+VS2013+OpenCV3.1环境配置
&1 源文件 VS2013: 链接:http://pan.baidu.com/s/1o8EKQq2 密码:open OpenCV3.1: 链接:http://pan.baidu.com/s/ ...
- 2016温碧霞爱情《爱在深秋》HD720P.国语中字
导演: 林家威编剧: 林家威 / 李非 / 黄国兆主演: 温碧霞 / 谭耀文 / 赵炳锐 / 方皓玟 / 王建成类型: 爱情制片国家/地区: 香港语言: 汉语普通话上映日期: 2016-01-22(中 ...
- 妙味WEB前端开发全套视频教程+项目实战+移动端开发(99G)
一共99GB的视频教程,全部存于百度网盘中,13个栏目,每个栏目里还划分有独立的小栏目 最基本的web前端学习介绍,到项目实战,再到移动端的开发,真正彻底掌握前端开发的精髓: 视频教程在线预览:(百度 ...
- LeetCode:Gray Code(格雷码)
题目链接 The gray code is a binary numeral system where two successive values differ in only one bit. Gi ...
- web.xml配置文件
一.web.xml里面的标签 <display-name> <context-param> <listener> <filter> 和 <filt ...