badges[i] is the number of runner i. Due to a mix-up, some numbers repeat.
In one step you can take any number and increase it by 1. Numbers can never go down.
Return the smallest number of steps after which all numbers are pairwise distinct.badges=[4, 4, 4, 1] → 3
Keep one 4, raise the second to 5 (1 step) and the third to 6 (2 steps), 3 in total.
badges=[2, 0, 2, 0, 1] → 5
One way is 2, 0, 3, 1, 4: the second 2 becomes 3 (+1), the second 0 becomes 1 (+1) and the 1 becomes 4 (+3), 5 in total.
badges=[3, 9, 6] → 0
The numbers are already distinct.
badges=[4, 4, 4, 1]
3
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.