Always smash the two heaviest stones. Use a max-heap.
Python has min-heap, so store negatives.
The rule requires repeatedly selecting the largest two; a heap supports that efficiently.
Always smash the two heaviest stones. Use a max-heap.
Python has min-heap, so store negatives.
The rule requires repeatedly selecting the largest two; a heap supports that efficiently.