首页 > 其他分享 >HDU 1087 (LIS)

HDU 1087 (LIS)

时间:2023-08-15 17:33:01浏览次数:37  
标签:1087 case HDU point int value chessmen Jumping LIS


Super Jumping! Jumping! Jumping!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28091    Accepted Submission(s): 12529

Problem Description
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.


The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some chessmen(棋子), and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.
 

Input
Input contains multiple test cases. Each test case is described in a line as follow:
N value_1 value_2 …value_N 
It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int.
A test case starting with 0 terminates the input and this test case is not to be processed.
 
Output
For each case, print the maximum according to rules, and one line one case.
 
Sample Input
3 1 3 2
4 1 2 3 4
4 3 3 2 1
0
 
Sample Output
4
10

3


#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int a[1010];
__int64 dp[1010];

int main()
{
    int n;
    while(~scanf("%d",&n)&&n)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            dp[i]=a[i];
        }
        __int64 ans=0;
        for(int i=0;i<n;i++)
        {
            for(int k=i+1;k<n;k++)
            {
                if(a[k]>a[i]&&dp[k]<dp[i]+a[k])
                    dp[k]=dp[i]+a[k];
            }
            ans=max(ans,dp[i]);
        }
        printf("%I64d\n",ans);
    }
    return 0;
}




标签:1087,case,HDU,point,int,value,chessmen,Jumping,LIS
From: https://blog.51cto.com/u_3936220/7091423

相关文章

  • HDU 3478
    CatchTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1389  AcceptedSubmission(s):682ProblemDescriptionAthiefisrunningaway!Wecanconsiderthecitywherehelocatesasanundirectedgrap......
  • HDU 5364
    DistributionmoneyTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):310  AcceptedSubmission(s):186ProblemDescriptionAFAwanttodistributionhermoneytosomebody.Shedividehermoneyintons......
  • HDU 5366
    ThemookjongTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):326  AcceptedSubmission(s):252ProblemDescription![](../../data/images/C613-1001-1.jpg)ZJiaQwanttobecomeastrongman,sohed......
  • HDU 2444
    TheAccomodationofStudentsTimeLimit:5000/1000MS(Java/Others)  MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3561  AcceptedSubmission(s):1656ProblemDescriptionThereareagroupofstudents.Someofthemmayknoweachother,......
  • HDU 1698(线段树 区间更新)
    JustaHookTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):23481    AcceptedSubmission(s):11758ProblemDescriptionInthegameofDotA,Pudge’smeathookisactuallythemosthorr......
  • 通过 Listener 解决 Slider 滑动冲突
    问题背景 在Flutter中,我们经常使用ScrollView+Slider这样的场景。但是在这样的场景下,存在用户体验并不好的问题:列表滑动的过程中Slider不能响应举例:1\.滑动未完成,Slider不能响应SingleChildScrollView在我们手指抬起的过程中,还是会有一定的惯性,列表不会立刻停止。它这......
  • CMakeLists语法详解
     https://www.jianshu.com/p/eb25baf5ca19set(Root"${CMAKE_CURRENT_SOURCE_DIR}")set(Base64${Root}/lib/libb64/src)include_directories(${OpenCV_INCLUDE_DIRS})include_directories(${Root})include_directories(${Root}/lib/libb64/include) include_dir......
  • Profession English
    runoutofsomething -touseallofsomething-tohavenothingleft.e.g. Theprinterhasrunoutofink.Canyouchangethecartridgeplease?Weonlyhaveacoupleofweekstofinishtheproject-we'rerunningoutoftime! figuresomethingout -......
  • 已知两个128维向量,向量格式为list,计算两个向量的余弦相似性
    计算两个向量的余弦相似度可以使用以下公式:余弦相似度=(向量A·向量B)/(||向量A||*||向量B||)其中,向量A·向量B表示向量A和向量B的点积(内积),||向量A||和||向量B||表示向量A和向量B的欧几里德范数(模)。下面是一个示例代码,展示如何计算两个128维向量的余弦相似度:imp......
  • Oracle启动监听报错:The listener supports no services或出现 unknown状态解决
    1、查看$ORACLE_HOME/network/admin/listener.ora文件中的host是否正确,能不能ping通2、查看$ORACLE_HOME/network/admin/tnsnames.ora文件中的host是否与listener.ora中的一致3、查看/etc/hosts文件中的127.0.0.1是不是localhost,listener.ora中host跟这里的是否一样4、登录数......