[HDU1087]Super Jumping! Jumping! Jumping!<dp>

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

题目大意:

  多组数据,一个n和一个n个元素的序列,找到和最大的严格上升子序列

思路:

  和严格上升序列有点像,不过dp数组dp[i]变成以i为结尾的序列的最大值。

就是需要对于每一个i维护一个小于这个元素的之前元素的最大严格上升子序列。

只上核心代码

int main(){
    while(scanf("%d",&n)!=EOF){
        if(n==0)return 0;
        for(int i=1;i<=n;i++)
            a[i]=read();
        memset(dp,0,sizeof(dp));
        ans=-1;
        for(int i=1;i<=n;i++){
            temp=-1;
            for(int j=0;j<i;j++)
                if(a[i]>a[j])temp=max(temp,dp[j]);
            dp[i]=temp+a[i];
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/Danzel-Aria233/p/12358004.html

时间: 2024-10-31 15:56:39

[HDU1087]Super Jumping! Jumping! Jumping!<dp>的相关文章

HDU1087 Super Jumping! Jumping! Jumping! 【DP】

Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 22510    Accepted Submission(s): 9907 Problem Description Nowadays, a kind of chess game called "Super Jumping!

HDU1087 Super Jumping! Jumping! Jumping!(简单dp)

题意:只能走比当前旗子大的旗子,不能回头,求走过最大的旗子的和. /* *********************************************** Author :devil Created Time :2015/12/21 20:58:22 ************************************************ */ #include <iostream> #include <algorithm> #include <cstri

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

Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34052    Accepted Submission(s): 15437 Problem Description Nowadays, a kind of chess game called “Super Jumping!

解题报告 HDU1087 Super Jumping! Jumping! Jumping!

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

hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24452    Accepted Submission(s): 10786 Problem Description No

HDU1087 Super Jumping! Jumping! Jumping! 最大连续递增子段

Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32561    Accepted Submission(s): 14689 Problem Description Nowadays, a kind of chess game called “Super Jumping!

HDU1087 Super Jumping! Jumping! Jumping!(LIS)

题目意思: http://acm.hdu.edu.cn/showproblem.php?pid=1087 此题的意思求最长上升子序列的和. 题目分析: 在求最长上升子序列的时候,不在保存最长的个数,而是保存他们的和即可. AC代码: /** *最长上升子序列问题+保存得到的分数 */ #include<iostream> #include<cstdio> #include<map> #include<cstring> #include<string&g

A-Super Jumping!Jumping! Jumping!

最开始题目都读不懂,懂了以后不会做,应该还是没有深入思考,这道题是上升序列,不要求连续,然后算出最大上身序列的和,= =可能直接求出会比较麻烦,所以我们可以比较变计算,这样就使用到了动态规划了. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[1005],dp[1005]; const int inf=99

zoj 1232 Adventure of Super Mario (Floyd+dp)

Adventure of Super Mario Time Limit: 2 Seconds      Memory Limit: 65536 KB After rescuing the beautiful princess, Super Mario needs to find a way home -- with the princess of course :-) He's very familiar with the 'Super Mario World', so he doesn't n