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. Android Studio编译开源项目(含NDK开发)常见报错

    1.未设置NDK的路径 Error:Execution failed for task ':library:ndkBuild'. > A problem occurred starting pr ...

  2. Camera和 tris,verts的优化

    Unity的Camera组件有很多可调节的参数,当需要做优化的时候,stats面板中的tris和verts这两个重点项都与Camera组件的参数有很大关系,有些参数的意义Unity手册说得不够详细,经 ...

  3. .net 音频转换 .amr 转 .mp3 (七牛转换法)

    .amr 用于移动设备的音频,压缩比比较大,多用于人声.通话,效果还行!所以,移动设备多采用amr格式来进行录存!比较常见的例子:通话录音,微信语音以及录音等! 这个鬼,用两个字来形容,就是“蛋疼”: ...

  4. java实现批量修改指定文件夹下所有后缀名的文件为另外后缀名的代码

    java实现批量修改指定文件夹下所有后缀名的文件为另外后缀名的代码 作者:Vashon package com.ywx.batchrename; import java.io.File; import ...

  5. c# 从DataGridVieew导出到excel

    public static bool DataGridViewToExcel(DataGridView dataGridView, bool isShowExcel) { int rowsQty = ...

  6. toast插件的简单封装(样式适用pc后台管理系统的场景)

    直接分三个步骤吧: 1.手写一个toast.vue组件 <template> <transition name="toast-fade"> <div ...

  7. 在windows上安装Jenkins---tomcat流

    在windows上安装Jenkins有两种方式: (1)jar流 在命令行中运行:java -jar jenkins.war 浏览器访问 localhost:8080,创建初始管理员帐号即可. (2) ...

  8. 洛谷 P1765 手机_NOI导刊2010普及(10)

    题目描述 一般的手机的键盘是这样的: 1 2 abc 3 def 4 ghi 5 jkl 6 mno 7 pqrs 8 tuv 9 wxyz * 0 # 要按出英文字母就必须要按数字键多下.例如要按出 ...

  9. jquery命名冲突

    nodeName是jquery的关键字

  10. vscode 打开新文件不替换旧文件

    设置 "workbench.editor.enablePreview": false