Powering the Hero (hard version)
EasyRating 1100CodeforcesHeap / Priority Queue
Approach hintTry it first, then revealHide
Push each bonus card's power into a max-heap as you pass it; when a hero card appears, give it the largest unused bonus in the heap, if there is one. O(n log n).