博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
题解报告:hdu 1087 Super Jumping! Jumping! Jumping!
阅读量:4881 次
发布时间:2019-06-11

本文共 1927 字,大约阅读时间需要 6 分钟。

Problem Description

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.
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.

Input

Input 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.

Output

For 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
解题思路:题意就是求单调递增子序列的最大和,数据比较小,改一下LIS的O(n^2)算法模板即可。
AC代码(15ms):
1 #include
2 using namespace std; 3 int n,maxsum,s[1005],dp[1005]; 4 int main(){ 5 while(~scanf("%d",&n)&&n){ 6 memset(dp,0,sizeof(dp));maxsum=0; 7 for(int i=0;i

 

转载于:https://www.cnblogs.com/acgoto/p/9538110.html

你可能感兴趣的文章
获取xml字符串中的属性值
查看>>
MySQL必知必会(数据分组,Group by和Having子句, Select子句的顺序)
查看>>
通过wireshark抓包来讲解HTTP中Connection: keep-alive头部的作用
查看>>
2015长春 HDU 5531 Rebuild
查看>>
Android之四种加载方式
查看>>
团队项目3.0
查看>>
【js】操作checkbox radio 的操作总结
查看>>
mysql复制表(同一数据库,不同数据库)
查看>>
Spring中 @Autowired标签与 @Resource标签
查看>>
面向对象的六大原则
查看>>
python的基本用法(三)字符串常用函数
查看>>
第二章例2-2
查看>>
Java8——快速入门手册(学习笔记)
查看>>
p2p-如何拯救k8s镜像分发的阿喀琉斯之踵
查看>>
linux之多进程
查看>>
iphone设置铃声
查看>>
python基础
查看>>
HDU 3277 最大流+二分
查看>>
Angular 学习笔记 :初识 $digest , $watch , $apply,浅析用法 。
查看>>
自动化测试优缺点思考
查看>>