Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
It is always optimal to halve the largest element.
What data structure allows for an efficient query of the maximum element?
Use a heap or priority queue to maintain the current elements.