博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Super Jumping! Jumping! Jumping!(hdu 1087 LIS变形)
阅读量:4313 次
发布时间:2019-06-06

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

Super Jumping! Jumping! Jumping!

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

Total Submission(s): 30163    Accepted Submission(s): 13507

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基本一样,
    : dp[i]=max(dp[i],dp[j]+a[i])  (a[j]<a[i])
  但一开始需要对dp进行初始化,wa了两发,dp[i]=a[i],这是dp[i]的最小值
 
1 #include 
2 #include
3 #include
4 using namespace std; 5 #define max(a,b) a>b?a:b 6 int dp[1005]; 7 int a[1005]; 8 int main() 9 {10 int n;11 int i,j;12 long long sum;13 freopen("in.txt","r",stdin);14 while(scanf("%d",&n)&&n)15 {16 memset(dp,0,sizeof(dp));17 for(i=0;i

 

 

转载于:https://www.cnblogs.com/a1225234/p/5223231.html

你可能感兴趣的文章
获取用户ip接口
查看>>
Django部署
查看>>
我与小娜(02):乘坐超速高铁,穿越时空60年
查看>>
H5取经之路——添加hover实现特定效果
查看>>
ultraiso:usb-hdd+ v2
查看>>
WINDOWS symbols
查看>>
SQL Server 2008 镜像的监控 - Joe.TJ -
查看>>
SQL Server DBA 文章:116篇 --DBA_Huangzj
查看>>
数据库Mysql性能优化
查看>>
程序猿是如何解决SQLServer占CPU100%的--马非码
查看>>
Shell之sed用法 转滴
查看>>
百度ueditor 拖文件或world 里面复制粘贴图片到编辑中 上传到第三方问题
查看>>
python基础之函数参数、嵌套、返回值、对象、命名空间和作用域
查看>>
公式推导【ASRCF//CVPR2019】
查看>>
Python(4)_Python中的数据类型
查看>>
HTTP 响应头信息
查看>>
cocos2dx中的层CCLayer
查看>>
Windows XP硬盘安装Ubuntu 12.04双系统图文详解
查看>>
【资料】哈代&拉马努金相关,悼文,哈佛演讲,及各种杂七杂八资料整理
查看>>
Use weechat (IRC client) on OS X. MacBook Pro
查看>>