21698_Missile

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

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

Pro.ID

21698

Title

Missile

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Long, long ago, country A invented a missile system to destroy the missiles from their enemy. That system can launch only one missile to destroy multiple missiles if the heights of all the missiles form a non-decrease sequence.

    But recently, the scientists found that the system is not strong enough. So they invent another missile system. The new system can launch one single missile to destroy many more enemy missiles. Basically, the system can destroy the missile from near to far. When the system is begun, it chooses one enemy missile to destroy, and then destroys a missile whose height is lower and farther than the first missile. The third missile to destroy is higher and farther than the second missile… the odd missile to destroy is higher and farther than the previous one, and the even missile to destroy is lower and farther than the previous one.

    Now, given you a list of the height of missiles from near to far, please find the most missiles that can be destroyed by one missile launched by the new system.

    输入

    The input contains multiple test cases.

    In each test case, first line is an integer n ( 0 < n ≤ 1000 ), which is the number of missiles to destroy. Then follows one line which contains n integers ( ≤ 109 ), the height of the missiles followed by distance.

    The input is terminated by n=0.

    输出

    Description

    Long, long ago, country A invented a missile system to destroy the missiles from their enemy. That system can launch only one missile to destroy multiple missiles if the heights of all the missiles form a non-decrease sequence.

    But recently, the scientists found that the system is not strong enough. So they invent another missile system. The new system can launch one single missile to destroy many more enemy missiles. Basically, the system can destroy the missile from near to far. When the system is begun, it chooses one enemy missile to destroy, and then destroys a missile whose height is lower and farther than the first missile. The third missile to destroy is higher and farther than the second missile… the odd missile to destroy is higher and farther than the previous one, and the even missile to destroy is lower and farther than the previous one.

    Now, given you a list of the height of missiles from near to far, please find the most missiles that can be destroyed by one missile launched by the new system.

    Input

    The input contains multiple test cases.

    In each test case, first line is an integer n ( 0 < n ≤ 1000 ), which is the number of missiles to destroy. Then follows one line which contains n integers ( ≤ 109 ), the height of the missiles followed by distance.

    The input is terminated by n=0.

    Output

    For each case, print the most missiles that can be destroyed in one line.

    Sample Input

    4
    5 3 2 4
    3
    1 1 1
    0

    Sample Output

    3
    1

    Source

    样例输入

    4
    5 3 2 4
    3
    1 1 1
    0

    样例输出

    3
    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部