题目链接:http://acm.split.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): 41523    Accepted Submission(s): 19239

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[i]从个数,变为数值之和。
 
 
代码如下:
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <set>
#define ms(a,b) memset((a),(b),sizeof((a)))
using namespace std;
typedef long long LL;
const double EPS = 1e-;
const int INF = 2e9;
const LL LNF = 2e18;
const int MAXN = 1e3+; int a[MAXN], dp[MAXN];
int n; int main()
{
while(scanf("%d", &n) &&n)
{
for(int i = ; i<=n; i++)
scanf("%d", &a[i]); ms(dp, );
for(int i = ; i<=n; i++)
for(int j = ; j<i; j++)
if(j== || a[i]>a[j])
dp[i] = max(dp[i], dp[j]+a[i]); int ans = -INF;
for(int i = ; i<=n; i++)
ans = max(ans, dp[i]);
printf("%d\n", ans);
}
}

HDU1087 Super Jumping! Jumping! Jumping! —— DP的更多相关文章

  1. HDU1087:Super Jumping! Jumping! Jumping!(DP)

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

  2. 【HDU - 1087 】Super Jumping! Jumping! Jumping! (简单dp)

    Super Jumping! Jumping! Jumping! 搬中文ing Descriptions: wsw成功的在zzq的帮助下获得了与小姐姐约会的机会,同时也不用担心wls会发现了,可是如何 ...

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

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

  4. 解题报告 HDU1087 Super Jumping! Jumping! Jumping!

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

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

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

  6. HDU1087 Super Jumping! Jumping! Jumping! 最大连续递增子段

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

  7. kuangbin专题十二 HDU1087 Super Jumping! Jumping! Jumping! (LIS)

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

  8. 杭电1087 Super Jumping! Jumping! Jumping!(初见DP)

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

  9. hdu1087 Super Jumping! Jumping! Jumping!---基础DP---递增子序列最大和

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意: 求递增子序列最大和 思路: 直接dp就可以求解,dp[i]表示以第i位结尾的递增子 ...

随机推荐

  1. 一些简单的JavaScript的方法

    <script type="text/javascript"> //js跳转 function UserMouserDown() { confirm('你确定要删除吗? ...

  2. OO第三次作业总结(JML)

    第三单元的课题是JML, 即java建模语言.JML是一种描述接的语言.通过前置条件和后置条件,描述一个模块的行为.本单元我们扮演一个项目中的一员,完成自己的一小部分工作,最终实现整个项目.而限制我们 ...

  3. POJ 1159 字符串匹配问题

    题目大意: 问至少添加几个字符才能保证这个字符串是个回文串 一开始想也想不到字符串匹配上,因为是找回文串,我们可以把已给字符串逆向得到一个新的字符串,然后比较两者得到最大匹配长度,最后总长度减去最大匹 ...

  4. 【BZOJ1061】志愿者招募(单纯形,对偶性)

    题意: 这个项目需要N 天才能完成,其中第i 天至少需要 Ai 个人. 布布通过了解得知,一共有M 类志愿者可以招募.其中第i 类可以从第Si 天工作到第Ti 天,招募费用 是每人Ci 元.新官上任三 ...

  5. apache cgi 模块安装

    apache安装,请参照:http://httpd.apache.org/docs/2.4/ 安装系统: Fedora release 21 (Twenty One)  (x64) 版本:Server ...

  6. python学习之-- redis模块基本介绍

    数据缓存系统: 1:mongodb:是直接持久化,直接存储于硬盘的缓存系统 2:redis: 半持久化,存储于内存和硬盘 3:memcache:数据只能存储在内存里的缓存系统关于memcache 学习 ...

  7. codeforces 873E(枚举+rmq)

    题意 有n(n<=3000)个人参与acm比赛,每个人都有一个解题数,现在要决定拿金牌的人数cnt1,拿银牌的人数cnt2,拿铜牌的人数cnt3,各自对应一个解题数区间[d1,c1],[d2,c ...

  8. sql多表更新

    --sql多表更新update PMS_Financial_Gathering set ShouldMoney=PMS_Contract_RentScheme.Rentfrom PMS_Financi ...

  9. Promise编程规范

    参考: http://www.cnblogs.com/dojo-lzz/p/4340897.html 闲话promise机制  http://www.cnblogs.com/lvdabao/p/es6 ...

  10. Java中常见的排序算法

    这是我摘取的一段英文资料.我认为学习算法之前,对各种排序得有个大致的了解: Sorting algorithms are an important part of managing data. At ...