题意:棋牌游戏如今,一种被称为“超级跳!跳!跳!“HDU是非常流行的。也许你是个好孩子,这个游戏知之甚少,所以我介绍给你吧。

可以玩游戏由两个或两个以上的球员 。它由一个棋盘(棋盘)和一些棋子(棋子),所有的棋子标记的正整数或“开始”或“结束”。玩家从起始点和终点终于跳进。在跳跃的过程中,玩家将访问路径中的棋子,但每个人都必须从一个棋子跳跃到另一个绝对更大(可以假定启动点是一个最小和终点是一个最大)。所有玩家都可以不走回头路。一个跳跃到下一个棋子,也可以去跨越许多的棋子,甚至你可以从起始点到终点直线。当然,在这种情况下,你得到零点。一个球员是一个胜利者,当且仅当,他可以根据他跳的解决方案,获得更大的成绩。请注意,你的分数来自你跳路径上的棋子价值的总和,


你的任务是输出的最大值,根据给定的棋子列表。

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087

题目解析:简单的来说就是求一个序列中一组递增序列的最大和;

如:1,9,6 ,2 ,4,10,5,3,2

它的最大递增序列和为20,递增序列为1,9,10

和最大递增序列有点相似,但算法不太相同;

运行时间:

9139511   Accepted 1087 15MS 432K 856 B C++

代码实现:

#include<stdio.h>
#include<cstring>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")
#define MAX 1005
int dp[MAX];//dp[i]存储与num[i]构成递增序列中和最大的一个;
int num[MAX];
int max(int a,int b)
{
return(a>b?a:b);
}
int main()
{
//freopen("input.txt","r",stdin);
int i,j,n;
while(scanf("%d",&n),n)
{
for(i=0;i<n;i++)
scanf("%d",&num[i]);
dp[0]=num[0];
int max1=0;
for(i=1;i<n;i++)
{
dp[i]=num[i];
for(j=0;j<i;j++)
{
if(num[i]>num[j])//找出比num[i]小的数num[j],dp[j]存储与num[j]构成递增序列中和最大的一个;所以加上num[i],也构成递增序列, {
if(dp[i]<dp[j]+num[i])//比较与num[i]能构成递增序列的这些序列和,找出最大的一个,
dp[i]=dp[j]+num[i];
}
}
max1=max(dp[i],max1);//max1为这些递增序列中和最大的一个;
}
printf("%d\n",max1);
}
return 0;
}

hdu1087Super Jumping! Jumping! Jumping!(最大递增序列和)的更多相关文章

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

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

  2. ACM: Racing Gems - 最长递增序列

    Racing Gems   You are playing a racing game.  Your character starts at the x axis (y = 0) and procee ...

  3. POJ 2533 Longest Ordered Subsequence 最长递增序列

      Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...

  4. uva103(最长递增序列,dag上的最长路)

    题目的意思是给定k个盒子,每个盒子的维度有n dimension 问最多有多少个盒子能够依次嵌套 但是这个嵌套的规则有点特殊,两个盒子,D = (d1,d2,...dn) ,E = (e1,e2... ...

  5. LeetCode 674. Longest Continuous Increasing Subsequence (最长连续递增序列)

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  6. UVA1619 栈维护递增序列

    先说这题的关键性质:每一个数应该只会计算一次,它有一个最小区间[L,R],即它在这个区间内是最小的,最小区间内任何包含它的子区间都不会大于F(L,R)=(a[L]+...+a[R])*min(a[l] ...

  7. [LeetCode] Longest Continuous Increasing Subsequence 最长连续递增序列

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence. E ...

  8. [LeetCode] Number of Longest Increasing Subsequence 最长递增序列的个数

    Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: I ...

  9. [Swift]LeetCode674. 最长连续递增序列 | Longest Continuous Increasing Subsequence

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...

随机推荐

  1. 【Hibernate】Illegal attempt to associate a collection with two open sessions

    今天在用Hibernate对对象进行修改操作的时候报了这个错. 之前一直没什么错误,但是今天修改了一下表结构,增加了一个OneToMany的映射. 所以在我获取对象,重新set一个变量之后就报了这个错 ...

  2. Android 开发 AirPlay Server

    安卓上开发  AirPlay Server  主要是参考了和修改了 DroidAirPlay项目 , 和Airplay 协议 1, 将DroidAirPlay 下载下来 2, Eclipse 新建一个 ...

  3. vhost文件设置

    #例子<VirtualHost *.82> #设置端口号为82 ServerName localhost #服务器名称 DocumentRoot "d:/Web" #文 ...

  4. Codeforces 479D - Long Jumps

    479D - Long Jumps, 480B - Long Jumps It , or . If we can already measure both x and y, output . Then ...

  5. 在VC6.0中能不能使用Duilib界面库呢?

    Duilib库的源代码是在vs2010下编译的,一般适用于vs2008及以上的版本开发使用,那么duilib能不能在vc6.0的工程中使用呢?如何在vc6.0中使用duilib库呢? 今天,由于工作要 ...

  6. iOS swift lazy loading

    Why bother lazy loading and purging pages, you ask? Well, in this example, it won't matter too much ...

  7. ONOS系统架构演进,实现高可用性解决方案

    上一篇文章<ONOS高可用性和可扩展性实现初探>讲到了ONOS系统架构在高可用.可扩展方面技术概况,提到了系统在分布式集群中怎样保证数据的一致性.在数据终于一致性方面,ONOS採用了Gos ...

  8. Verilog之case语句

    verilog设计进阶 时间:2014年5月6日星期二 主要收获: 1.学会使用case语句: 2.学会使用随机函数$random. $random: 1.函数说明:$random函数调用时返回一个3 ...

  9. iOS UITextField垂直居中

    textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

  10. vim添加删除多行注释

    CTRL+V进入可视化模式 移动光标上移或者下移,选中多行的开头 选择完毕后,按大写的的I键,此时下方会提示进入“insert”模式,输入你要插入的注释符 最后按ESC键,你就会发现多行代码已经被注释 ...