22796_Antimonotonicity

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

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

Pro.ID

22796

Title

Antimonotonicity

Title链接

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

AC

22

Submit

59

Ratio

37.29%

时间&空间限制

  • Time Limit: 20000/10000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    I have a sequence Fred of length n comprised of integers between 1 and n inclusive. The elements of Fred are pairwise distinct. I want to find a subsequence Mary of Fred that is as long as possible and has the property that:

    Mary0 > Mary1 < Mary2 > Mary3 < ...

    输入

    The first line of input will contain a single integer T expressed in decimal with no leading zeroes. T will be at most 50. T test cases will follow.

    Each test case contains a single line. A line describing a test case is formatted as follows:

    n  Fred0  Fred1  Fred2  ...  Fredn-1

    where n and each element of Fred is an integer expressed in decimal with no leading zeroes. No line will have leading or trailing whitespace, and two adjacent integers on the same line will be separated by a single space. n willbe at most 30000.

    输出

    Description

    I have a sequence Fred of length n comprised of integers between 1 and n inclusive. The elements of Fred are pairwise distinct. I want to find a subsequence Mary of Fred that is as long as possible and has the property that:

    Mary0 > Mary1 < Mary2 > Mary3 < ...

    Input

    The first line of input will contain a single integer T expressed in decimal with no leading zeroes. T will be at most 50. T test cases will follow.

    Each test case contains a single line. A line describing a test case is formatted as follows:

    n  Fred0  Fred1  Fred2  ...  Fredn-1

    where n and each element of Fred is an integer expressed in decimal with no leading zeroes. No line will have leading or trailing whitespace, and two adjacent integers on the same line will be separated by a single space. n willbe at most 30000.

    Output

    For each test case, output a single integer followed by a new line --- the length of the longest subsequence Mary of Fred with the desired properties.

    Sample Input

    4
    5 1 2 3 4 5
    5 5 4 3 2 1
    5 5 1 4 2 3
    5 2 4 1 3 5

    Sample Output

    1
    2
    5
    3

    Source

    样例输入

    4
    5 1 2 3 4 5
    5 5 4 3 2 1
    5 5 1 4 2 3
    5 2 4 1 3 5

    样例输出

    1
    2
    5
    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部