values and an integer budget. In one step you may pick any element and increase it by 1, and you can take at most budget steps in total.
What is the largest number of equal elements the array can end up with?values=[2, 6, 5, 9], budget=4 → 2
Raise 5 to 6 (1 step) and there are two 6s. Three equal values are out of reach: lifting 2 and 5 to 6 costs 5 steps, and lifting 5 and 6 to 9 costs 7.
values=[3, 1, 3, 2], budget=3 → 4
2 → 3 takes one step and 1 → 3 takes two, so all four values become 3.
values=[10, 20, 30], budget=5 → 1
Any two values differ by more than 5, so no two can be made equal and the answer is 1.
values=[2, 6, 5, 9], budget=4
2
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.