Error
|
|
---|---|
@Ibrahim Nash | 5765 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4993 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1272 |
@bt8816103042 | 739 |
@rohitanand | 495 |
@codeantik | 479 |
@shalinibhataniya1097 | 472 |
@amrutakashikar2 | 464 |
@thealchemist627 | 456 |
@dalwainazism125 | 453 |
@shivanandp12345678910 | 453 |
@akashkale117 | 453 |
@SherlockHolmes3 | 447 |
Complete Leaderboard |
Given an array of N elements, the task is to find the number of ways of choosing pairs with maximum difference.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an integer N and the second line contains N space separated array elements.
Output:
For each test case, print the count of pairs in new line.
Constraints:
1 <= T <= 100
1 <= N <= 105
1 <= A[i] <= 105
Example:
Input:
2
5
3 2 1 1 3
3
1 2 3
Output:
4
1
Explanation:
Input : A[] = {3, 2, 1, 1, 3}
Output : 4
Here, the maximum difference you can find is 2
which is from (1, 3).
No. of ways of choosing it:
1) Choosing the first and third elements,
2) Choosing the first and fourth elements,
3) Choosing the third and fifth elements,
4) Choosing the fourth and fifth elements.
Hence ans is 4.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes