22800_Trainsorting

2022-5-16 18:22| 发布者: Hocassian| 查看: 33| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506967885700-Problem List-采集的数据-后羿采集器.html

Pro.ID

22800

Title

Trainsorting

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22800

AC

4

Submit

13

Ratio

30.77%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Erin is an engineer. She drives trains. She also arranges the cars within each train. She prefers to put the cars in decreasing order of weight, with the heaviest car at the front of the train.

    Unfortunately, sorting train cars is not easy. One cannot simply pick up a car and place it somewhere else. It is impractical to insert a car within an existing train. A car may only be added to the beginning and end of the train.

    Cars arrive at the train station in a predetermined order. When each car arrives, Erin can add it to the beginning or end of her train, or refuse to add it at all. The resulting train should be as long as possible, but the cars within it must be ordered by weight.

    Given the weights of the cars in the order in which they arrive, what is the longest train that Erin can make?

    输入

    The first line contains an integer 0 ≤ n ≤ 2000, the number of cars. Each of the following n lines contains a non-negative integer giving the weight of a car. No two cars have the same weight.

    输出

    Description

    Erin is an engineer. She drives trains. She also arranges the cars within each train. She prefers to put the cars in decreasing order of weight, with the heaviest car at the front of the train.

    Unfortunately, sorting train cars is not easy. One cannot simply pick up a car and place it somewhere else. It is impractical to insert a car within an existing train. A car may only be added to the beginning and end of the train.

    Cars arrive at the train station in a predetermined order. When each car arrives, Erin can add it to the beginning or end of her train, or refuse to add it at all. The resulting train should be as long as possible, but the cars within it must be ordered by weight.

    Given the weights of the cars in the order in which they arrive, what is the longest train that Erin can make?

    Input

    The first line contains an integer 0 ≤ n ≤ 2000, the number of cars. Each of the following n lines contains a non-negative integer giving the weight of a car. No two cars have the same weight.

    Output

    Output a single line with an integer giving the number of cars in the longest train that can be made with the given restrictions.

    Sample Input

    3
    1
    2
    3

    Sample Output

    3

    Source

    样例输入

    3
    1
    2
    3

    样例输出

    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部