P19561 [HackerEarth] Rahul has recently learnt about array inversions. An array a has N integers, indexed from 0 to N - 1. Formally, the number of inversions is the number of pairs (i, j) such that 0 ≤ i a
提高
题目描述

Rahul has recently learnt about array inversions. An array a has N integers, indexed from 0 to N - 1. Formally, the number of inversions is the number of pairs (i, j) such that 0 ≤ i < j < N and a[i] > a[j].

Now, he wants to find the lexicographically smallest left rotation of the array such that number of inversions are maximized. The index of rotation is defined as the number of elements from the front that need to left rotated. For example, given the array with elements a[0], a[1], a[2], ..., a[N - 1], the rotation with index 1 will be a[1], a[2], ..., a[N - 1], a[0]; the rotation with index k will be a[k], a[k + 1], ..., a[N - 1], a[0], ..., a[k - 1].

Note that in case, multiple lexicographically equal rotations are found to have the largest number of inversions, you should print the smallest index of rotation.

An array a of integers is lexicographically smaller than another array b if a[i] = b[i] for all indices 0 ≤ i < k and a[k] < b[k].

Input
The first line shall contain a single integer T, denoting the number of test cases to follow. Each of the test cases contain 2 lines each. The first line has an integer N, the size of array and the next line has N integers separated by a single space.

Output
You should output exactly T lines, each containing 2 numbers, the selected index for rotation and the maximum number of inversions found, separated by a single space.

Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 10^5
1 ≤ A[i] ≤ 10^9

SAMPLE INPUT
2
3
1 2 3
4
1 1 1 1

SAMPLE OUTPUT
1 2
0 0

Explanation

Case 1:
Possible rotations are:
[1, 2, 3] with index 0 and inversions 0
[2, 3, 1] with index 1 and inversions 2
[3, 1, 2] with index 2 and inversions 2

Notice that [2, 3, 1] is lexicographically smaller than [3, 1, 2]. Hence, answer is 1 2.
Notice that [1, 2, 3] is the smallest lexicographical but it cannot be considered since the number of inversions is lesser.

Case 2:
All the elements are equal, so we have all rotations as lexicographically equal and same number of inversions.
We must choose the smallest index and hence answer is 0 0.

输入格式

见题面

输出格式

见题面

样例输入
10 10 3862237 921874364 163683419 921874364 163683419 163683419 81555504 3862237 81555504 163683419 10 356031079 307846202 859041813 844090328 356031079 307846202 859041813 844090328 356031079 307846202 10 575089995 900565421 301759376 431216990 575089995 900565421 301759376 431216990 575089995 900565421 9 661594211 729135768 487491862 907308228 661594211 729135768 487491862 907308228 661594211 10 795167568 435054374 481563817 435054374 398272572 435054374 435054374 398272572 398272572 795167568 4 576831355 544199937 212720236 346931862 9 472339885 355472229 660679599 472101746 472339885 355472229 660679599 472101746 472339885 10 425149649 890777067 860777991 862174562 425149649 890777067 860777991 862174562 425149649 890777067 10 918377285 358995671 918377285 918377285 18211080 69320059 918377285 358995671 358995671 358995671 10 41366574 292497755 211820551 310674603 41366574 292497755 211820551 310674603 41366574 292497755
样例输出
4 6 2 7 0 6 2 5 0 5 4 6 2 7 3 7 2 5 3 4