Super Jumping! Jumping! Jumping!

                                                                                                             Time Limit: 2000/1000
MS (Java/Others)   

                                                                                                            Memory Limit: 65536/32768
K (Java/Others)



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

题目意思很好懂,但所给的测试样例太水(hdu上的样例都是这样),以为要用最长单调递增子序列,但一直没有好的思路,,后来TJY小田想出了一个很好的思路;就是用两层循环,一层输入,一层查询,只要输入的数据其前面的数据满足条件,就直接用另外一个数组相加储存最大和,那么,,需要满足什么条件呢:

请看样例:

4  1 2 3 4;输出10,1前面没有谁比他小,故1的位置就是1,而2前面有1,故2的位置是3,同理3的位置是6,4的位置是10,看出来了吧,前面的数据小就加起来;

再看这组数据:

  5 1 3 2 5 6 ;输出是15,这组应该没什么问题;

6  4 9 6 8 5 10;输出28,来分析看,9的位置是13,而6的位置是10,8的位置是18,5的位置是9,10的位置是28;

只要前面的数据比当前数据小就加起来;

但  7 4 9 2 6 8 5 10;输出应该是28,用刚刚的方法就不行了,因为2这个数据很小,后面的数据都会加上它 ,而实际上它是不算在递增序列中的,所以,,看代码:

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1000+10;
int a[N],c[N];
int main()
{
int n,i,j,k;
while(scanf("%d",&n)&&n)
{
memset(c,0,sizeof(c));
for(i=1; i<=n; i++)
{
scanf("%d",&a[i]);
c[i]=a[i],k=0;
for(j=1; j<i; j++)
{
if(a[j]<a[i])
c[i]=max(c[i],a[i]+c[j]);//手推上面的样例就会明白的;
}
}
sort(c+1,c+n+1);
printf("%d\n",c[n]);
}
return 0;
}

HDU-1087Super Jumping! Jumping! Jumping!的更多相关文章

  1. HDU 1087:Super Jumping! Jumping! Jumping!(LIS)

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

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

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

  3. HDU 1087 E - Super Jumping! Jumping! Jumping! DP

    http://acm.hdu.edu.cn/showproblem.php?pid=1087 设dp[i]表示去到这个位置时的最大和值.(就是以第i个为结尾的时候的最大值) 那么只要扫描一遍dp数组, ...

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

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

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

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

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

    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: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  8. HDU 1087 Super Jumping! Jumping! Jumping

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

  9. hdu 1155 Bungee Jumping

    http://acm.hdu.edu.cn/showproblem.php?pid=1155 Bungee Jumping Time Limit: 2000/1000 MS (Java/Others) ...

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

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

随机推荐

  1. Mysql常用命令行大全(转)

    第一招.mysql服务的启动和停止 net stop mysql net start mysql 第二招.登陆mysql 语法如下: mysql -u用户名 -p用户密码 键入命令mysql -uro ...

  2. 【solr filter 介绍--转】http://blog.csdn.net/jiangchao858/article/details/54989025

    Solr的Analyzer分析器.Tokenizer分词器.Filter过滤器的区别/联系 Analyzer负责把文本字段转成token stream,然后自己处理.或调用Tokenzier和Filt ...

  3. Springboot 1.X 在Weblogic 中的发布

    springboot在tomcat中的兼容性很好,但是如果要把Springboot项目发布在weblogic,尤其是老版本的Weblogic就会出现各种问题.经过本人的不懈努力及查询资料,终于将Spr ...

  4. apache配置多域名

    环境:mac,其他环境也可做参考 hosts配置 eg:sudo vim /etc/hosts 127.0.0.1 www.testphalcon.com apache配置 找到apache对应安装目 ...

  5. 【转】windows server 2012 安装 VC14(VC2015) 安装失败解决方案

    系统环境如下:cmd命令行-输入 systeminfo 如下图 - The VC14 builds require to have the Visual C++ Redistributable for ...

  6. qt 设置阴影 不显示黑色边框

    this->setAttribute(Qt::WA_TranslucentBackground);

  7. 洛谷 P3038 [USACO11DEC]牧草种植Grass Planting

    题目描述 Farmer John has N barren pastures (2 <= N <= 100,000) connected by N-1 bidirectional road ...

  8. 一个PHP开发APP接口的视频教程

    感觉php做接口方面的教程很少,无意中搜到了这个视频教程,希望能给一些人带来帮助http://www.imooc.com/learn/163

  9. SAP成都研究院姚瑶:软件质量保证工作的变迁

    大家好,我是来自SAP成都研究院Revenue Cloud 团队的质量工程师 , yoyo.很高兴可以和大家分享我个人的工作体会.每个团队都有QE(Quality Engineer), 相信大家对QE ...

  10. mysql踩坑记录之limit和sum函数混合使用问题

    问题复盘本次复盘会用一个很简单的订单表作为示例. 数据准备订单表建表语句如下(这里偷懒了,使用了自增ID,实际开发中不建议使用自增ID作为订单ID) CREATE TABLE `order` ( `i ...