ACM 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.
InputInput contains multiple test cases. Each test case is described in a line as follow:
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.
OutputFor each case, print the maximum according to rules, and one line one case.
Sample Input
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
Sample Output
4
10
3
/*
Name: Super Jumping! Jumping! Jumping!
Copyright:
Author:
Date: 11/08/17 13:26
Description: 访问棋子,下一步要访问的棋子要比目前的棋子的标记数要大,且不能返回,求最大数
用dp算法思想,用dp数组记录到目前的棋子的最优走法,直至最后一个棋子。
*/ #include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int NUM = ;
int chessman[NUM],dp[NUM];
int main()
{
int N,ans;
while(cin>>N && N)
{
for(int i = ; i < N; i++)
cin>>chessman[i]; dp[] = chessman[];
ans = dp[];
for(int i = ; i < N; i++)
{
dp[i] = chessman[i];
for(int j = ; j < i; j++)
{
if(chessman[j] < chessman[i] && chessman[i] + dp[j] > dp[i]) /*dp思想*/
dp[i] = chessman[i] + dp[j]; ans = max(ans,dp[i]);
}
}
cout<<ans<<endl; }
return ;
}
ACM Super Jumping! Jumping! Jumping!的更多相关文章
- HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)
传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...
- (最大上升子序列) 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!(求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 ...
- HDU1087 Super Jumping! Jumping! Jumping! —— DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limi ...
- hdu 1087 Super Jumping! Jumping! Jumping!(dp 最长上升子序列和)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 ------------------------------------------------ ...
- E - Super Jumping! Jumping! Jumping!
/* Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popula ...
- Super Jumping! Jumping! Jumping!
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...
- DP专题训练之HDU 1087 Super Jumping!
Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...
随机推荐
- python 异常 反射
异常 反射 一.异常处理: AttributeError 试图访问一个对象没有的树形,比如foo.x,但是foo没有属性x IOError 输入/输出异常:基本上是无法打开文件 ImportError ...
- python 类的进阶
类的进阶 一 isinstance(obj,cls)和issubclass(sub,super) class Foo: def __init__(self,name): self.name = nam ...
- [转]使用awk批量杀进程的命令
1. ps -ef|grep aaa|grep -v grep 这是大家很熟悉的命令,这里就不再多说,就是从当前系统运行的进程的进程名中包含aaa关键字的进程. 2. 后面部分就是awk命令了,一般a ...
- scrapy爬取极客学院全部课程
# -*- coding: utf-8 -*- # scrapy爬取极客学院全部课程 import scrapy from pyquery import PyQuery as pq from jike ...
- if__name__ == '__main__'
# a.py import b def x(): print('x') b.y #b.py import a def y(): print('y') a.x() #执行b.py引发异常 首先,执行b. ...
- zookeeper初探
安装三台linux虚拟机,安装好java环境,并配置好网络以及host文件,分别改好hostname为node0.node1.node2 上传下载好的zookeeper文件到node0的/usr/lo ...
- [Nginx]-外部多端口映射Https443端口配置
https服务器配置完成后,域名访问默认匹配至443端口,如果想同时通过https域名网址来请求多个对外服务,就需要在Nginx配置里来对请求进行规则判断,并匹配至相应的内部端口,这也是Nginx反向 ...
- [NOI 2016]区间
Description 在数轴上有 $n$ 个闭区间 $[l_1,r_1],[l_2,r_2],...,[l_n,r_n]$.现在要从中选出 $m$ 个区间,使得这 $m$ 个区间共同包含至少一个位置 ...
- 【网络流】【BZOJ1221】【HNOI2001】软件开发
原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1221 题意:你有3种方法进行对毛巾的处理,不同的处理方法有不同的cost,问你要如何规划才 ...
- HDU 5412 CRB and Queries 动态整体二分
Problem Description There are N boys in CodeLand.Boy i has his coding skill Ai.CRB wants to know who ...