Problems > Sum of Pair Minimums > Editorial

Sum of Pair Minimums — Solution & Editorial

Back to the Problem

Sort descending: the element at 0-based position i is the minimum against exactly i larger-or-equal predecessors, contributing x·i.

Complexity: O(N log N)