Pro.ID21759 TitleDales and Hills Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21759 AC0 Submit0 Ratio- 时间&空间限制描述Let's consider a number sequence a1, ..., aN. We call the continuous subsequence ai, ... , aj, ..., ak (1 ≤ i < j < k ≤ N) of the sequence a hill if at < at+1 for any i ≤ t < j and at > at+1 for any j ≤ t < 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 i ≤ t < j and at < at+1 for any j ≤ t < 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 < k ≤ N) of the sequence a hill if at < at+1 for any i ≤ t < j and at > at+1 for any j ≤ t < 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 i ≤ t < j and at < at+1 for any j ≤ t < 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 Sample Output 1 3 Source 样例输入2 样例输出1 3 作者 |