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]的最小值
 
 #include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define max(a,b) a>b?a:b
int dp[];
int a[];
int main()
{
int n;
int i,j;
long long sum;
freopen("in.txt","r",stdin);
while(scanf("%d",&n)&&n)
{
memset(dp,,sizeof(dp));
for(i=;i<n;i++)
{
scanf("%d",&a[i]);
dp[i]=a[i];
}
sum=;
for(i=;i<n;i++)
{
for(j=;j<i;j++)
{
if(a[j]<a[i])
dp[i]=max(dp[i],dp[j]+a[i]);
}
sum=max(sum,dp[i]);
}
printf("%d\n",sum);
}
return ;
}
 

Super Jumping! Jumping! Jumping!(hdu 1087 LIS变形)的更多相关文章

  1. hdu 1087(LIS变形)

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

  2. hdu 5256 LIS变形

    给一个数列,问最少修改多少个元素使数列严格递增.如果不是要求“严格”递增,那就是求最长不降子序列LIS,然后n-LIS就是答案.要严格递增也好办,输入的时候用每个数减去其下标处理一下就行了. /* * ...

  3. hdu 5125(LIS变形)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5125 题解: 这个题dp[i][0],dp[i][1]数组分别记录在第i个位置取a[i]和b[i]时 ...

  4. hdu 2881(LIS变形)

    Jack's struggle Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  5. HDU 1087 Super Jumping! Jumping! Jumping

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

  6. (最大上升子序列) Super Jumping! Jumping! Jumping! -- hdu -- 1087

    http://acm.hdu.edu.cn/showproblem.php?pid=1087   Super Jumping! Jumping! Jumping! Time Limit:1000MS  ...

  7. HDU 1087 Super Jumping! Jumping! Jumping! 最长递增子序列(求可能的递增序列的和的最大值) *

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

  8. HDU 1087 简单dp,求递增子序列使和最大

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

  9. HDU 1069&&HDU 1087 (DP 最长序列之和)

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

随机推荐

  1. 在JasperReport中填充JavaBean(4)

    使用Parameters参数对象传递字符串的示例,本节将演示打印List接口中Userinfo.java实体类的示例,打印的数据源不是来自于Parameters对象,而是JRBeanCollectio ...

  2. 配置Kestrel 网址Urls

    配置Kestrel 网址Urls ASP.NET Core中如何配置Kestrel Urls呢,大家可能都知道使用UseUrls() 方法来配置. 今天给介绍全面的ASP.NET Core 配置 Ur ...

  3. Linux_Shell type

    Recommendation is to use the bash shell, because he is strong enough, and absorbed the useful proper ...

  4. js 浮点数加减问题

      /**  ** 加法函数,用来得到精确的加法结果  ** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显.这个函数返回较为精确的加法结果.  ** 调用:accAd ...

  5. Python 的开发环境

    建议在Windows 下开发,成本低廉,简单,效率高. 综合下:开发的程序,Python  Django (Mysql,PostgreSQL) Nginx Redis ,这一组组合可以适应不同的平台, ...

  6. 如何判断是REQUEST请求是来自移动终端还是来自PC端

    public bool IsMoblie()        {            string agent = (Request.UserAgent + "").ToLower ...

  7. HDU 1394 Minimum Inversion Number(线段树 或 树状数组)

    题目大意:给出从 0 到 n-1 的整数序列,A0,A1,A2...An-1.可将该序列的前m( 0 <= m < n )个数移到后面去,组成其他的序列,例如当 m=2 时,得到序列 A2 ...

  8. hdu3410-Passing the Message(RMQ,感觉我写的有点多此一举。。。其实可以用单调栈)

    What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten ar ...

  9. shell数组(产生不同的随机数)

    #!/bin/bash # declare -a ARRAY read -p "Please input num[1-39]:" EMENUM #对比新生成的随机数是否重复 fun ...

  10. 修改UISearchBar输入框字体颜色

    UITextField *searchField = [mySearchBar valueForKey:@"_searchField"]; searchField.textColo ...