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 ...
随机推荐
- Json转换成DataTable
今天看到Json转DataTable的例子,总结一下.... using System; using System.Collections; using System.Collections.Gene ...
- Outlook2010规则:尝试操作失败,找不到某个对象
可以尝试通过清除规则的方法 启动 Outlook 并删除基于客户端的规则:outlook /cleanclientrules 如果失败,再执行这句 启动 Outlook 并删除基于服务器端的规则:ou ...
- 继承&封装
扩展一个已有的类,并且继承该类的属性和行为这种方式成为继承. 实例 public class Polygon { public int sides; public double area; publi ...
- 原生sql的各种问题
1.nutz有方法自动根据数据库建models吗?2.select * from a a没有建相应的models怎么取结果?3.可以直接操作result,而不是在callback里面设置吗? wend ...
- RxSwift の Observable とは何か
Qiita にあげていた記事ですが.ここにもバックアップをとっておきます この記事は.2017/09/15〜17 に早稲田大学 理工学部 西早稲田キャンパスで開催される iOSDC Japan 201 ...
- dw2018修改为中文
dw2018 英文版修改为中文, 把zh_CN文件夹内的内容复制到en_US文件夹内并替换, 或者重命名zh_CN文件夹为en_US
- 谈谈网页中的ajax
一个页面上有很多的ajax请求,这样的页面右键查看源文件是没法看到全部的html.事实上,这种网页也是从正常的html页面改造过来的,常用的一个场景是,同一个区域大量循环,在动态页面里(比如jsp等) ...
- (4.33)sql server2014内存数据库(内存中OLTP(In-Memory OLTP))
查看文章:https://blog.51cto.com/ultrasql/1626514
- RabbitMQ基础知识(转载)
RabbitMQ基础知识(转载) 一.背景 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现.AMQP 的出现其实也是应了广大人民群众的需 ...
- JS 从100里面随机取10个数比大小
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...