HDOJ1087 Super Jumping! Jumping! Jumping!【逆推】

简介:
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
复制代码
#include <stdio.h>
int a[1001],b[1001];
int n;
int main()
{
    int i,j,tmax,res;
    while (~scanf("%d",&n))
    {
        if(n==0)
            break;
        for (i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            b[i]=-1;
        }
        res=-1;
        for (i=n-1;i>=0;i--)
        {
            tmax=0;
            for (j=i+1;j<n;j++)
            {
                if(a[j]>a[i]&&b[j]>tmax)
                    tmax=b[j];
            }
            b[i]=a[i]+tmax;
            res=res>b[i]?res:b[i];
        }
        printf("%d\n",res);
    }
}
复制代码

 


本文转自ZH奶酪博客园博客,原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/05/09/2491331.html,如需转载请自行联系原作者

相关文章
Codeforces Round #192 (Div. 2) (330B) B.Road Construction
要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目。 要求两个城市之间不超过两条道路,那么所有的城市应该是连在一个点上的,至于这个点就很好找了,只要找到一个没有和其他点有道路限制的即可。
40 0
|
机器学习/深度学习
1257:Knight Moves 2021-01-09
1257:Knight Moves 2021-01-09
AtCoder Beginner Contest 225 F.String Cards(dp)
AtCoder Beginner Contest 225 F.String Cards(dp)
90 0
AtCoder Beginner Contest 214 F - Substrings(subsequence DP)
AtCoder Beginner Contest 214 F - Substrings(subsequence DP)
96 0
|
机器学习/深度学习
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
120 0
|
人工智能
Educational Codeforces Round 98 (Rated for Div. 2)B-Toy Blocks
You are asked to watch your nephew who likes to play with toy blocks in a strange way. He has n boxes and the i-th box has ai blocks. His game consists of two steps: he chooses an arbitrary box i; he tries to move all blocks from the i-th box to other boxes.
260 0
|
Go
HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
85 0
HDOJ/HDU 1241 Oil Deposits(经典DFS)
HDOJ/HDU 1241 Oil Deposits(经典DFS)
87 0
HDOJ 1098 Ignatius's puzzle
HDOJ 1098 Ignatius's puzzle
117 0