Super Jumping! Jumping! Jumping!

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5   Accepted Submission(s) : 1
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
 
Author
lcy
 这道题,开始没怎么看懂,以为是连续的升段和,怎么这么简单,然后错了2边,后来发现是可以这样重组的....
3 1 3 2 升段有{1},{3},{2},{1,3},{1,2}...所以最大是 4
再比如 7 3 2 1 2 3 4 7  最大值为{1 2 3 4 7}=17.....这样话,关键是如何遍历找到他们的每一个数,对应的最大升段和....
百度百科里有着一个公式;
 for(i=;i<n;i++)
{
temp=;
for(j=;j<i;j++)
{
if(arr[i]>arr[j]&&dp[j]>temp)
temp=dp[j];
}
dp[i]=temp+arr[i];
}

上面的公式,运用的范围极为广泛....注意记下来!!

代码如下:

 #include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,i,j,temp;
while(cin>>n,n)
{
vector<int>arr(n,);
vector<int>dp(n,);
for(i=;i<n;i++)
{
cin>>arr[i];
}
int max=;
for(i=;i<n;i++)
{
temp=;
for(j=;j<i;j++)
{
if(arr[i]>arr[j]&&dp[j]>temp)
temp=dp[j];
}
dp[i]=temp+arr[i]; max=max>dp[i]?max:dp[i];
}
cout<<max<<endl;
}
return ;
}
 

HDUOJ----Super Jumping! Jumping! Jumping!的更多相关文章

  1. HDU - 1087 Super Jumping!Jumping!Jumping!(dp求最长上升子序列的和)

    传送门:HDU_1087 题意:现在要玩一个跳棋类游戏,有棋盘和棋子.从棋子st开始,跳到棋子en结束.跳动棋子的规则是下一个落脚的棋子的号码必须要大于当前棋子的号码.st的号是所有棋子中最小的,en ...

  2. E - Super Jumping! Jumping! Jumping!

    /* Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popula ...

  3. Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. May ...

  4. DP专题训练之HDU 1087 Super Jumping!

    Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is ve ...

  5. hdu 1087 Super Jumping! Jumping! Jumping! 简单的dp

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. Super Jumping! Jumping! Jumping!——E

    E. Super Jumping! Jumping! Jumping! Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO forma ...

  7. HDU 1087 Super Jumping! Jumping! Jumping! 最大递增子序列

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  8. HDU 1087 Super Jumping! Jumping! Jumping

    HDU 1087 题目大意:给定一个序列,只能走比当前位置大的位置,不可回头,求能得到的和的最大值.(其实就是求最大上升(可不连续)子序列和) 解题思路:可以定义状态dp[i]表示以a[i]为结尾的上 ...

  9. HDU 1087 Super Jumping! Jumping! Jumping! (DP)

    C - Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format: ...

  10. HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)

    Super Jumping! Jumping! Jumping! Problem Description Nowadays, a kind of chess game called “Super Ju ...

随机推荐

  1. Pycharm 增加 run 控制台缓冲行数

    Yes, you can change the value of idea.cycle.buffer.size in bin/idea.properties under the PyCharm ins ...

  2. RHPAM 7.2安装

    1.产品架构 2.安装过程 下载相应介质 JBoss EAP (jboss-eap-7.2.0.zip)   下载地址 https://developers.redhat.com/products/e ...

  3. retrofit okhttp RxJava bk Gson Lambda 综合示例【配置】

    项目地址:https://github.com/baiqiantao/retrofit2_okhttp3_RxJava_butterknife.git <uses-permission andr ...

  4. GoLang中 json、map、struct 之间的相互转化

    1. golang 中 json 转 struct <1. 使用 json.Unmarshal 时,结构体的每一项必须是导出项(import field).也就是说结构体的 key 对应的首字母 ...

  5. 红黑树,TreeMap,插入操作

    红黑树 红黑树顾名思义就是节点是红色或者黑色的平衡二叉树,它通过颜色的约束来维持着二叉树的平衡.对于一棵有效的红黑树二叉树而言我们必须增加如下规则: 1.每个节点都只能是红色或者黑色 2.根节点是黑色 ...

  6. supervisord不重启更新配置文件

    二.更新新的配置到supervisord supervisorctl update 1 三.重新启动配置中的所有程序 supervisorctl reload

  7. Sql server management studio: cannot find one or more components

      Install VS2010 SHELL 独立组件 https://www.microsoft.com/en-US/download/details.aspx?id=1366 运行安装程序,rep ...

  8. Jquery 获取table当前行内容

    $("a[name='checkOriginal']").click(function () { var parent = $(this).parent().parent().fi ...

  9. spring boot测试工具(自带)

    启动spring boot 项目(一般是openapi) http://localhost:8888/swagger-ui.html 端口号可以自己配

  10. Spring 在XML中声明切面/AOP

    在Spring的AOP配置命名空间中,我们能够找到声明式切面选择.看以下: <aop:config> <!-- AOP定义開始 --> <aop:pointcut/> ...