Phoenix and Towers
MediumRating 1400CodeforcesHeap / Priority Queue
Approach hintTry it first, then revealHide
Because every block is at most x tall, always placing the next block on the currently shortest tower keeps all heights within x of each other. A min-heap of (height, tower) pairs does this in O(n log m).