wrong answer in salary

my approach is that all salaries after increasing will become equal.let it be max,now we subtract every number in our original array from max,let summation of differences be sum. now sum must be multiple of n-1.why?because in each step we can increase array by n-1.
so we take max equal to maximum element in the array and increase it till we get sum a multiple of n-1.and our answer is max - minimum element.

The simplest test where you get WA is
3
0 2 2
The correct answer is 4 according to editorial.
But you return 1.

Your mistake is that when your sum is divisible by (n-1)
it is not always possible to achieve the goal without increasing the maximum.
Indeed, here the sum is 2 and divisible by 2 but the only way to increase salaries with saving maximum is to increase 0 two times which is not proper operation.

2 Likes

thanks ,now i got it
n-1 can be distributed amongst them in anyway,not only as we desire

You can mark my answer as accepted one to your question :wink:

//