Problem
You are given an array �A of size �N.
Let �M be the minimum value present in the array initially.
In one operation, you can choose an element ��Ai (1≤�≤�)(1≤i≤N) and an integer �X (1≤�≤100)(1≤X≤100), and set ��=�Ai=X.
Determine the minimum number of operations required to make �M the maximum value in the array �A.
Input Format
- The first line of input will contain a single integer �T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer �N – the size of the array.
- The next line of each test case contains �N space-separated integers �1,�2,…,��A1,A2,…,AN – the elements of the array.
Output Format
For each test case, output on a new line, the minimum number of operations required to make �M the maximum value in the array �A.
Constraints
- 1≤�≤1001≤T≤100
- 1≤�≤1001≤N≤100
- 1≤��≤1001≤Ai≤100
Sample 1:
Input
Output
3 2 1 2 4 2 2 3 4 1 1
1 2 0
Explanation:
Test case 11: The minimum value in the array, �M, is initially 11. We can use one operation as following:
- Choose �2A2 and set it as �=1X=1. Thus, the final array becomes [1,1][1,1].
Since all elements of the final array are 11, the maximum value of the array is now 11. It can be shown that this is the minimum number of operations required to do so.
Test case 22: The minimum value in the array, �M, is initially 22. We can use two operations as following:
- Choose �4A4 and set it as �=2X=2. Thus, the array becomes [2,2,3,2][2,2,3,2].
- Choose �3A3 and set it as �=2X=2. Thus, the array becomes [2,2,2,2][2,2,2,2].
Since all elements of the final array are 22, the maximum value of the array is now 22.
Test case 33: The minimum value in the array, �M, is initially 11. It is also the maximum value of the array. Hence, no operations are required.
More Info