HDU 1087 Super Jumping! Jumping! Jumping!
2016-03-31 10:54
344 查看
Super Jumping! Jumping! Jumping!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31037 Accepted Submission(s): 13910
[align=left]Problem Description[/align]
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.
![](http://acm.hdu.edu.cn/data/images/1087-1.jpg)
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, print the maximum according to rules, and one line one case.
[align=left]Sample Input[/align]
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
[align=left]Sample Output[/align]
4
10
3
[align=left]Author[/align]
lcy
[align=left]Recommend[/align]
We have carefully selected several similar problems for you: 1176 1159 1069 1058 1231
动态规划,,类似于求最长上升子序列
#include<stdio.h> #include<string.h> #include<algorithm> #define INF 0xfffffff using namespace std; int dp[110000],a[110000]; int main() { int n,i,j,k,l,m,ans; while(scanf("%d",&n),n) { memset(dp,0,sizeof(dp)); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=n;i++) { ans=-INF; for(j=0;j<i;j++) { if(a[i]>a[j]) { ans=max(ans,dp[j]); } } dp[i]=ans+a[i]; } ans=-INF; for(i=0;i<=n;i++) { if(dp[i]>ans) ans=dp[i]; } printf("%d\n",ans); } return 0; }
相关文章推荐
- PMAC上位机编程
- JSP程序设计:Servlet配置问题
- IO完成端口
- 通过代码创建label 计算最佳尺寸 让其自适应文本高度或宽度
- scala Calendar中获取月份遇到“坑”
- 常见的响应式布局方式
- 可用的 SublimeText3 注册码
- 自定义弹出提示框
- js(头像,图片)上传,如何立即展示?图片详解。
- 关于分布式事务、两阶段提交协议、三阶段提交协议
- 微软 Build 2016年开发者大会发布多项功能升级
- 电梯调度算法的改进
- flume实现kafka到hdfs实时数据采集 - 有负载均衡策略
- CentOS(Rehat)下查看系统、cpu信息指令
- 数据库并发访问、事务与锁的关系
- caffe+windows+matlab
- odoo8.0下selection_add的使用
- java23中设计模式——结构模式——Composite(组合) 3ff8
- 让开发自动化: 用 Eclipse 插件提高代码质量
- oracle 安装错误码