Super Jumping! Jumping! Jumping!

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

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

【题意】

  这个游戏可以由两个人或两个人以上玩。它由一个棋盘和一些棋子组成,所有的棋子都用一个正整数或“开始”或“结束”来标记。玩家从起点开始,最终必须跳到终点。在跳跃的过程中,玩家将访问路径中的棋子,但是每个人都必须从一个棋子跳到另一个更大的棋子(您可以假设起点是最小的,终点是最大的)。所有的玩家都不能倒退。一次跳跃可以从一个棋子跳到下一个棋子,也可以跨越许多棋子,甚至可以直接从起点到终点。当然在这种情况下你得到的是0。当且仅当一名运动员能根据他的跳跃方案得到一个更大的分数时,他就是赢家。注意,你的分数来自于你跳跃路径上棋子的价值总和。

  我们需要根据给定的棋子列表输出最大值。

【代码】

#include<bits/stdc++.h>
using namespace std;
int sum[],a[];
int main(){
int i,n,mmax=,maxa=;
while(cin>>n && n){
memset(a,,sizeof(a));
for(i=; i<=n; i++){
cin>>a[i];
}
for(i=; i<=n; i++){
mmax = ;
for(int j=; j<i; j++)
if(a[j] < a[i])
mmax = max(sum[j],mmax);
sum[i] = mmax + a[i];
maxa = max(maxa,sum[i]);
}
cout<<maxa<<endl;
maxa = ;
}
return ;
}

HDU 1087 最大递增子序列的更多相关文章

  1. hdu 1087 最大递增子序列和

    #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #defin ...

  2. HDU 1087 最大上升子序列的和

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

  3. hdu 1087 最大上升子序列的和(dp或线段树)

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

  4. hdu 1087 最大递增和

    思路和LIS差不多,dp[i]为i结尾最大值 #include <iostream> #include <string> #include <cstring> #i ...

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

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

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

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

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

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

  8. HDU 1257 最少拦截系统 最长递增子序列

    HDU 1257 最少拦截系统 最长递增子序列 题意 这个题的意思是说给你\(n\)个数,让你找到他最长的并且递增的子序列\((LIS)\).这里和最长公共子序列一样\((LCS)\)一样,子序列只要 ...

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

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

随机推荐

  1. Java 基础 - Set接口 及其实现类HashSet/LinkedHashSet/TreeSet

    笔记: /**Set接口 及其实现类 * 公用操作同Collection: * * ①size(),clear()②isEmpty(),③contains(),④add()方法 和remove()方法 ...

  2. 用IE滤镜实现多种常用的CSS3效果

    CSS3是当下非常火的一个话题之一,很多浏览器都已经开始支持这一特性,然后IE这个拥有庞大用户群体的平台,却无法提供这样的支持,即便是IE9发布,也无法改变这一事实,然而,幸运的是,IE并非在这方面毫 ...

  3. Codeforces Round #584 B. Koala and Lights

    链接: https://codeforces.com/contest/1209/problem/B 题意: It is a holiday season, and Koala is decoratin ...

  4. Codeforces Round #585 (Div. 2) B. The Number of Products(DP)

    链接: https://codeforces.com/contest/1215/problem/B 题意: You are given a sequence a1,a2,-,an consisting ...

  5. [Google Guava] 1.5-Throwables:简化异常和错误的传播与检查

    原文链接 译者: 沈义扬 异常传播 有时候,你会想把捕获到的异常再次抛出.这种情况通常发生在Error或RuntimeException被捕获的时候,你没想捕获它们,但是声明捕获Throwable和E ...

  6. PHP mysqli_close() 函数

    关闭先前打开的数据库连接: <?php $con=mysqli_connect("localhost","my_user","my_passwo ...

  7. 原生JS实现图片上传并预览功能

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. flutter布局-1-column

    1.mainAxisAlignment:主轴布局方式,column主轴方向是垂直的方向   mainaxis.png 默认值:MainAxisAlignment.start: start ,沿着主轴方 ...

  9. MySQL 锁(lock与latch)

    一.什么是锁 锁机制用于管理对共享资源的并发访问,它是数据库系统区别于文件系统的一个关键特性. 数据库系统使用锁是为了支持对共享资源的并发访问,提供数据的完整性和一致性. InnoDB存储引擎锁的实现 ...

  10. Shell 02 数据运算/条件测试

    一.整数运算工具 1.使用expr命令(运算两边必须有空格,引用变量时必须加$符号) [root@svr5 ~]# x=10    //定义变量x expr $x + 10      20       ...