#K286. Minimum Removals for Maximum Constraint

    ID: 24830 Type: Default 1000ms 256MiB

Minimum Removals for Maximum Constraint

Minimum Removals for Maximum Constraint

You are given an array of integers and an integer X. Your task is to calculate the minimum number of elements that need to be removed so that the maximum value in the remaining array is less than or equal to X. In other words, you need to achieve:

$$\max(\text{array}) \le X$$

If the array already satisfies the condition, no removals are needed. It is always possible to remove the required elements (even if that means the resulting array is empty).

Note: The removal strategy is to count and remove each element in the array that is greater than X. The order of the elements does not affect the outcome.

inputFormat

The input begins with an integer T, the number of test cases. Each test case is described as follows:

  • The first line contains two integers N and X where N is the number of elements in the array and X is the threshold.
  • The second line contains N space-separated integers representing the array.

outputFormat

For each test case, output a single integer: the minimum number of elements that need to be removed so that the maximum element in the remaining array is \( \le X \).

Each answer should be printed on a new line.

## sample
4
5 4
5 1 3 7 2
4 6
3 8 7 10
3 5
1 2 3
6 13
22 12 14 9 11 13
2

3 0 2

</p>