题意:棋牌游戏如今,一种被称为“超级跳!跳!跳!“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. 第一篇:NSOperation的概念

    一.说明 NSOperation的作口:配合使用NSOperation和NSOperationQueue也能实现多线程 NSOperation和NSOperationQueue实现多线程的具体步骤: ...

  2. Python中函数式使用

    对于链表来讲,有三个内置函数非常有用: filter(),map() 以及 reduce(). filter(function, sequence) 返回一个 sequence(序列),包括了给定序列 ...

  3. 在VS上配置OpenCV

    这几篇帖子讲的挺仔细的,而且不坑,结合看看就没问题了~~ http://www.cnblogs.com/cuteshongshong/p/4057193.html http://my.phirobot ...

  4. java:转换时间格式为String

    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss"); Date curDate = new ...

  5. Android广播——短信拦截

    MainActivity.java package com.example.broadcasttest; import android.content.Intent; import android.c ...

  6. 06-C语言运算符2

    目录: 一.类型转换 二.条件运算符 三.逗号运算符 四.运算符优先级 回到顶部 一.类型转换 1.类型升级,浮点型高于整型,长整型高于整型,有符号与无符号取有符号. 2.在C语言中,类型转换没有提示 ...

  7. mysql not in、left join、IS NULL、NOT EXISTS 效率问题记录

    原文:mysql not in.left join.IS NULL.NOT EXISTS 效率问题记录 mysql not in.left join.IS NULL.NOT EXISTS 效率问题记录 ...

  8. 查看linux下各数据类型的大小

    代码如下: #include<stdio.h> int main() { printf("int:%d bytes\n",sizeof(int)); printf(&q ...

  9. 自己用js写的两个日历控件

    前一阵写了两个日历控件,做了简单的封装,发出来共朋友们参考. 第一个日历控件,条状的日历. (使用方法:调用initBarTime(id,evn),第一个参数是要渲染div的id,第二个参数是点击日期 ...

  10. python变量传递给系统命令的方法

    python程序内执行shell命令可以有几种方式,在http://www.cnblogs.com/xuxm2007/archive/2011/01/17/1937220.html 里都有详细介绍. ...