Sum of Pair Maximums — Solution & Editorial
Sort ascending: position i's element is the maximum of i pairs. (Check: pair-min total + pair-max total = (N−1)·∑a.)
Complexity: O(N log N)
Sort ascending: position i's element is the maximum of i pairs. (Check: pair-min total + pair-max total = (N−1)·∑a.)
Complexity: O(N log N)