博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU-1087-Super Jumping! Jumping! Jumping!(线性DP, 最大上升子列和)
阅读量:6981 次
发布时间:2019-06-27

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

Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 49819    Accepted Submission(s): 23076

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

 

DP入门题;

#include 
#include
#define N 1100int main(){ int n; while(~scanf("%d", &n) && n) { int max; int a[N], dp[N] = {0,}; int i, j; scanf("%d", &a[0]); dp[0] = a[0]; for(i=1; i
max) { max = dp[j]; } } dp[i] = a[i] + max; } max = 0; for(i=0; i
max) { max = dp[i]; } } printf("%d\n", max); } return 0;}

 

转载于:https://www.cnblogs.com/gaojinmanlookworld/p/10586855.html

你可能感兴趣的文章
小知识点
查看>>
scrollview gridview
查看>>
获取用户所属浏览器和设备
查看>>
20135306黄韧 信息安全系统设计基础期中学习总结
查看>>
Magento(麦进斗)安装问题
查看>>
大数据概述
查看>>
客户端动态调用WCF服务中的方法
查看>>
v-cloak,v-text,v-html的基本使用
查看>>
[POI2009]KAM-Pebbles BZOJ1115 [ 待填坑 ] 博弈
查看>>
Web充斥着存在漏洞的过期JavaScript库
查看>>
%f%g%e区别
查看>>
Ubuntu Vim YouCompleteMe 安装
查看>>
修改360浏览器 标题栏 显示的文字
查看>>
在Centos 7下编译openwrt+njit-client
查看>>
微软重新释出MS10-015 解决蓝屏问题
查看>>
计算机组成原理-第3章-3.1
查看>>
约瑟夫环 猴子选大王
查看>>
win7安装mysql-8.0.13-winx64
查看>>
jQuery事件
查看>>
golang笔记——struct
查看>>