hdoj--1087--Super Jumping! Jumping! Jumping!(贪心)
Super Jumping! Jumping! Jumping!

The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In
the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping
can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his
jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.
N value_1 value_2 …value_N
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
4
10
3
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int num[100100],dp[100100];
int main()
{
int n;
while(scanf("%d",&n),n)
{
memset(dp,0,sizeof(dp));
memset(num,0,sizeof(num));
for(int i=0;i<n;i++)
scanf("%d",&num[i]);
int maxx=-0x3f3f3f;
for(int i=0;i<n;i++)
{
dp[i]=num[i];
for(int j=0;j<i;j++)
{
if(num[j]<num[i])
//每次去比j大的数,因为从0开始,从小到大,保证是上升序列
//因为这里对长度没有要求,和最大不一定就是最长的,所以dp不用存长度
dp[i]=max(dp[i],dp[j]+num[i]);
}
maxx=max(maxx,dp[i]);
}
printf("%d\n",maxx);
}
return 0;
}
hdoj--1087--Super Jumping! Jumping! Jumping!(贪心)的更多相关文章
- Hdoj 1087.Super Jumping! Jumping! Jumping!
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- 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 ...
- HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *
Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64 ...
- DP专题训练之HDU 1087 Super Jumping!
Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...
- 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! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
随机推荐
- tp5数据库操作 模型层
一.数据模型作用 相同功能代码不用重复写多次 二.创建方式 在模块下建立model文件夹,php文件,文件名为数据库表名,其中类为数据库表名,继承Model类,模型层即为此表 namespace ap ...
- Educational Codeforces Round 35
Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion C ...
- android反编译查看源码,apk解压后XML乱码解决
1:找了好几个软件都不能图形化的解决反编译,很不舒服,最后找了个还算顺手的,顺便保存下. 2:使用过程 <1> apk转jar apktoolkit工具 <2> 查看jar源码 ...
- Tomcat应用通过Nat123部署到外网(Tomcat+Nat123)
这里吐槽下,我先想到的方式是用花生壳域名解析,但是花生壳坑太多不易新手操作,用户体验做的不好.然后度娘后才知道有Nat123这个比花生壳简易操作的软件. 1.到nat123官网下载客户端 http: ...
- iOS中容易混淆的知识点(持续更新中)
1.成员变量和属性的区别 @interface Person : NSObject { NSString *_sex; } @property (nonatomic, copy) NSString * ...
- Win8.1应用开发之适配器模式(C#实现)
实际上适配器模式是用于解耦.设想一下我们的程序模块A在与模块B打交道时,需要在许多地方多次使用B中某个类的方法,而负责开发B的程序猿Tom还未完全实现该类,会随时更改该类中的方法,那么当Tom在修改时 ...
- 「JavaSE 重新出发」05.03.03 使用反射编写泛型数组代码
Employee[] a = new Employee[100]; // ... // array is full a = Arrays.copyOf(a, 2 * a.length); 如何编写这样 ...
- sql_1
order by SELECT Company, OrderNumber FROM Orders ORDER BY Company DESC; SELECT Company, OrderNumber ...
- Zookeeper分布式锁解决方案具体代码
定义一个公共资源订单生成类: package com.itmayiedu.lock; import java.text.SimpleDateFormat; import java.util.Date; ...
- Asp.Net IHttpHandler介绍
ASP.NET响应Http请求时常用的两个处理接口是IHttpHandler和IHttpModule. 一般的,IHttpHandler用来处理一类特定的请求,比如对每个*.asp, *.aspx文件 ...