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,如需转载请自行联系原作者

相关文章
|
9月前
Codeforces Round #192 (Div. 2) (330B) B.Road Construction
要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目。 要求两个城市之间不超过两条道路,那么所有的城市应该是连在一个点上的,至于这个点就很好找了,只要找到一个没有和其他点有道路限制的即可。
22 0
|
12月前
|
机器学习/深度学习
1257:Knight Moves 2021-01-09
1257:Knight Moves 2021-01-09
AtCoder Beginner Contest 225 D - Play Train(双向链表 并查集)
AtCoder Beginner Contest 225 D - Play Train(双向链表 并查集)
119 0
|
机器学习/深度学习
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
96 0
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
97 0
HDU-1029,Ignatius and the Princess IV
HDU-1029,Ignatius and the Princess IV
|
Go
HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)
72 0
|
人工智能
HDOJ 1028 Ignatius and the Princess III(递推)
HDOJ 1028 Ignatius and the Princess III(递推)
103 0
HDOJ 1098 Ignatius's puzzle
HDOJ 1098 Ignatius's puzzle
105 0