21759_DalesandHills

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

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

Pro.ID

21759

Title

Dales and Hills

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Let's consider a number sequence a1, ...,  aN. We call the continuous subsequence ai, ... , aj, ..., ak (1 ≤ i < j < kN) of the sequence a hill if at < at+1 for any it < j and at > at+1 for any jt < k. In this case we call min{ j-i , k-j } the height of the hill. Similarly, we call the continuous subsequence a dale if at > at+1 for any it < j and at < at+1 for any jt < k. In this case we call min{ j-i , k-j } the depth of the dale.

    Compute the height of the highest hill and the depth of the deepest dale in the given sequence.

    输入

    The first line of the input file contains T (1 ≤ T ≤ 100000), the number of test cases. The test cases follow, occupying two lines each. The first of the two lines contains N (1 ≤ N ≤ 1000000), the second the members of the sequence, separated by spaces. The sum of values of N over all test cases in the file does not exceed 1000000. The absolute values of the members of the sequences do not exceed 100000.

    输出

    Description

    Let's consider a number sequence a1, ...,  aN. We call the continuous subsequence ai, ... , aj, ..., ak (1 ≤ i < j < kN) of the sequence a hill if at < at+1 for any it < j and at > at+1 for any jt < k. In this case we call min{ j-i , k-j } the height of the hill. Similarly, we call the continuous subsequence a dale if at > at+1 for any it < j and at < at+1 for any jt < k. In this case we call min{ j-i , k-j } the depth of the dale.

    Compute the height of the highest hill and the depth of the deepest dale in the given sequence.

    Input

    The first line of the input file contains T (1 ≤ T ≤ 100000), the number of test cases. The test cases follow, occupying two lines each. The first of the two lines contains N (1 ≤ N ≤ 1000000), the second the members of the sequence, separated by spaces. The sum of values of N over all test cases in the file does not exceed 1000000. The absolute values of the members of the sequences do not exceed 100000.

    Output

    The output file should consist of T lines and each line should contain two integers, the height of the highest hill and the depth of the deepest dale. If there are no hills or no dales, output 0 in the corresponding position.

    Sample Input

    2
    10
    4 4 1 6 3 2 1 2 5 7
    10
    2 3 4 5 6 7 8 9 10 9

    Sample Output

    1 3
    1 0

    Source

    样例输入

    2
    10
    4 4 1 6 3 2 1 2 5 7
    10
    2 3 4 5 6 7 8 9 10 9

    样例输出

    1 3
    1 0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部