Super Jumping! Jumping! Jumping!

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 8   Accepted Submission(s) : 7
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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
 

解释一下题意:此题就是找序列中最大升序子序列的和。

比如  1 3 2 中升序序列有:{1}{3}{2}{1,3}{1,2}。所以最大为1+3=4;

代码如下:

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
    int i,j;
    int n;
    int sum[1005],num[1005];
    int Max;
    while(scanf("%d",&n),n)
    {
        Max=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&num[i]);
            sum[i]=num[i];
            for(j=0;j<i;j++)
            {
                if(num[i]>num[j])
                {
                    sum[i]=max(sum[i],sum[j]+num[i]);
                }
                Max=max(Max,sum[i]);
            }
        }
        cout<<Max<<endl;
    }
    return 0;
}

转载于:https://www.cnblogs.com/lzmfywz/articles/2353268.html

HDU OJ Super Jumping! Jumping! Jumping!相关推荐

  1. [C#] 逆袭——自制日刷千题的AC自动机攻克HDU OJ

    前言 做过杭电.浙大或是北大等ACM题库的人一定对"刷题"不陌生,以杭电OJ为例:首先打开首页(http://acm.hdu.edu.cn/),然后登陆,接着找到"Onl ...

  2. hdu 1087 Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  3. hdu 1087 Super Jumping! Jumping! Jumping! 动态规划

    Super Jumping! Jumping! Jumping! Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K ...

  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!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  6. HDU 1087 Super Jumping! Jumping! Jumping!【最大递增子段和】

    Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!&quo ...

  7. 最长上升子序列模板 hdu 1087 Super Jumping! Jumping! Jumping!

    Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...

  8. hdu - 1087 - Super Jumping! Jumping! Jumping!

    题意:求最大升序和. 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 -->>设d[i]表示以第i个数为终点的最大升序和,然后从第1 ...

  9. HDU 1087 [Super Jumping! Jumping! Jumping!]动态规划

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意:有N个格子,每个格子有数值.从原点开始跳,可以跳到任何一个位置:在某一个位置,只能跳到 ...

最新文章

  1. 一个牛逼的 多级缓存 实现方案!
  2. IE9上特定网站不断崩溃的故障
  3. 记一次MyBatis的错误
  4. Java面向对象(18)--final关键字使用
  5. java浮点型需知_java使用数字类型注意事项
  6. JavaScript玩转机器学习:模型转换
  7. JavaWeb项目开发案例精粹-第3章在线考试系统-005action层
  8. 传统人工势场法---经典算法
  9. dinic算法 c 语言,网络流(dinic算法)
  10. Mysql 查询每个班级的成绩最好前三名(并列与不并列的情况)
  11. 郭盛华是如何登上神坛?令全世界认识了中国的黑科技
  12. AM调制解调matlab实验报告,MATLAB仿真AM调制解调 无线通信实验报告.doc
  13. 上位机开发之三菱Q系列PLC通信实践
  14. Modbus协议应用纪实
  15. 51nod 1299 监狱逃离 树形dp
  16. 思维误区:努力学习与有效学习!不要做无用功
  17. gateway官网解读(三)
  18. 关于Servlet编程(2)
  19. 自然科学基金本子撰写
  20. untracked working tree file已解决

热门文章

  1. python 贴吧自动回复机-Python实现微信自动回复机器人详细教程
  2. 精通python设计模式-Python设计模式
  3. python在线编译-在线编译python
  4. python和java一样吗-三分钟看懂Python和Java的区别
  5. python语言入门与精通-终于懂得python从入门到精通教程
  6. python零基础怎么学-python 零基础该怎么学?
  7. python编程从入门到精通pdf-跟老齐学Python:从入门到精通 完整版PDF[7MB]
  8. python语言能干什么-python语言可以干什么
  9. python基础实例-Python基础之字符串常见操作经典实例详解
  10. 济南python工资一般多少钱-济南Python人工智能编程