Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32179    Accepted Submission(s): 14487

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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std; int num[];
int dp[]; int main()
{
int n;
while(scanf("%d",&n)!=EOF&&n)
{
int ans=;
memset(dp,,sizeof(dp));
for(int i=; i<=n; i++)
scanf("%d",&num[i]);
for(int i=; i<=n; i++)
for(int j=; j<i; j++)
{if(num[i]>num[j])
dp[i]=max(dp[i],dp[j]+num[i]);
if(ans<dp[i])
ans=dp[i];
}
printf("%d\n",ans);
}
return ;
}

最新文章

  1. python批量下载图片的三种方法
  2. DataTable插件指定某列不可排序
  3. Dojo特效(翻译)
  4. js获取网页的各种高度和宽度
  5. 重构17-Extract&#160;Superclass(提取父类)
  6. Delphi 712操作word
  7. 4.1 spring-alias 标签的解析;
  8. 一个类似于QQ语音聊天时的拖拽移动悬浮小球
  9. JavaScript多线程初步学习
  10. node.js 入门(一)安装
  11. VC学习笔记: 1. Window程序内部运行机制
  12. Java面向对象(封装性概论)
  13. BZOJ 1061: [Noi2008]志愿者招募 [单纯形法]
  14. 访问https 报错ssl 协议异常
  15. Unittest中TestCase类中定义的几个特殊方法
  16. C# 基础 new 、override实现多台区别
  17. C# 单例模式的五种写法
  18. linux系统编程之进程(六):父进程查询子进程的退出,wait,waitpid
  19. adb root : adbd cannot run as root in production builds
  20. kafka集群与zookeeper集群 配置过程

热门文章

  1. SiteMesh2-sitemesh.xml的ParameterDecoratorMapper映射器的用法
  2. CI 日志类
  3. Spring Web Flow 入门demo(二)与业务结合 附源代码
  4. UIView的层介绍
  5. Leetcode题解(5):L58/Length of Last Word
  6. SSD性能优化记录
  7. Java 定时任务之Quartz
  8. C语言控制台窗体图形界面编程(总结)
  9. CAGradientLayer功能
  10. Codeforces Round #250 (Div. 1) D. The Child and Sequence 线段树 区间求和+点修改+区间取模