题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1087

Super Jumping! Jumping! Jumping!

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

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
分析:
普通的LIS问题,但是题目不是要求LIS序列的长度,而是LIS序列元素的值
改一下DP方程就ok
dp[0]=a[0]
dp[i]=max(dp[j]+a[i])  a[j]<a[i]且j<i
代码如下:
#include<cstring>
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==)
break;
int a[n];
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int dp[n];
dp[]=a[];
for(int i=;i<n;i++)
{
int max_v=;
for(int j=;j<i;j++)
{
if(a[j]<a[i])
{
if(max_v<dp[j])
{
max_v=dp[j];
}
}
}
dp[i]=max_v+a[i];
}
int max_v=dp[];
for(int i=;i<n;i++)
{
if(max_v<dp[i])
{
max_v=dp[i];
}
}
printf("%d\n",max_v);
}
return ;
}

回来更新一下:

今天训练赛又遇到了这个题目

贴一下代码(比一开始精简了点,因为理解了)

#include<bits/stdc++.h>
using namespace std;
#define INF 99999
int main()
{
//最大递增子序列和
int n;
while(cin>>n,n)
{
int a[n];
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int dp[n];
memset(dp,,sizeof(dp));
dp[]=a[];
int ans=;
for(int i=;i<n;i++)
{
int maxx=;
for(int j=;j<i;j++)
{
if(a[j]<a[i])
{
maxx=max(dp[j],maxx);
}
}
dp[i]=maxx+a[i];
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
}
return ;
}

HDU 1087 Super Jumping! Jumping! Jumping!(求LSI序列元素的和,改一下LIS转移方程)的更多相关文章

  1. HDU 1087 Super Jumping! Jumping! Jumping

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

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

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

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

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

  4. hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 200 ...

  5. 题解报告:hdu 1087 Super Jumping! Jumping! Jumping!

    Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very ...

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

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

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

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

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

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

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

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

随机推荐

  1. css-扩展选择器

    (1)关联选择器 <div><p>aaaaaaaaaaaa</p></div> * 设置div标签里面p标签的样式,嵌套标签里面的样式 div p{ b ...

  2. h5新属性

    <!DOCTYPE html> <html lang="en"> <head> <meta id="viewport" ...

  3. RxJava重温基础

    RxJava是什么 a library for composing asynchronous and event-based programs using observable sequences f ...

  4. oracle 和 mysql 和区别

    1.mysql 有枚举类型,oracle 没有; mysql不支持number.varchar2类型,报错.2.oracle 支持全外连接,mysql 不支持 select e.ename, e.sa ...

  5. oracle常见的等待事件说明

    转自 http://blog.itpub.net/29371470/viewspace-1063994/ 1. Buffer busy waits 从本质上讲,这个等待事件的产生仅说明了一个会话在等待 ...

  6. 二、ionic如何使用外链

    1.ionic如何使用外链并返回原有页面? html如下: 对应的controller如下: (function() { angular.module('app').controller('extra ...

  7. pytts3语音合成遇到的中文问题

    在使用pytts3语音合成时,遇到中文语音错乱.程序代码本身很简单,也是网上公认的一种写法: #coding: UTF-8import pyttsx3; engine = pyttsx3.init() ...

  8. 【转】Kettle发送邮件步骤遇到附件名是中文名变成乱码的问题解决办法

    原文:http://www.ukettle.org/thread-607-1-1.html 本帖最后由 大白菜 于 2016-3-7 10:18 编辑 导语:看到群里很多朋友问Kettle发送邮件附件 ...

  9. JavaScript DOM 編程藝術(2版) 綜合實例Band js代碼

    function addLoadEvent(func){ var oldonload=window.onload; if(typeof window.onload!='function') { win ...

  10. android 常用adb 及linux 命令

    一.ADB相关 adb shell:进入连接的USB调试模式设备shell命令行下 adb tcpip 5555:将USB连接的调试及的连接方式改为网络远程模式进行调试 这里端口为5555(adb 默 ...