Make Them Equal
HardRating 2000CodeforcesConstructive Algorithms
Approach hintTry it first, then revealHide
Index 1 can transfer any amount, so treat it as a bank: gather every value there with at most two operations per index, then hand out the average. Check that the bank always holds enough to round each a[i] up to a multiple of i.