Problem 2448 · Hard

Minimum Cost to Make Array Equal

Each change costs its weight per step, so the best target is the weighted median of the values: sort by value and stop where half the total cost is reached.

Open the interactive visualisation