Problem:-
You are given an array of positive integers. Your task is to add a minimum number of non-negative integers to the array such that the floor of an average of array becomes less than or equal to .
The floor of an average of array containing integers is equal to . Here is the floor function. You are given test cases.
Input format
- The first line contains a single integer that denotes the number of test cases. For each test case:
- The first line contains two space-separated integers and denoting the length of the array and the required bound.
- The second line contains space-separated integers denoting the integer array
Output format
For each test case (in a separate line), print the minimum number of non-negative integers that should be added to array such that the floor of an average of array is less than or equal to .
Constraints
In the first test case, we have , , . The current floor of average of is .
If we add the element to the array, the array becomes . The floor of average of is . Therefore, the minimum number of non-negative integers we need to add in this case is .
In the second test case, we have , , . The current floor of average of is . Therefore, we don't need to add any non-negative integer to .
(c++) Code:-