Binary search a given k so that when all numbers larger than k are changed to k, the sum of the array is equal to a given sum b.