Problem 2681 · Hard
Sort the strengths, then carry a running weighted sum so each hero is the strongest in its group exactly once.
Open the interactive visualisation