AmazonOA #261
Maximize Cluster Power
估计中等可在线判题
Choose some disjoint triples of servers; each group's power is the median of its three values. Any server may go unused, and building no group at all is also allowed; maximize the sum of the groups' medians.
输入格式
The first line contains n; the second line contains the powers. The original text had no numeric bounds; this site uses 1≤n≤200000, −10^9≤power≤10^9; this site includes negative powers, and groups with negative gain need not be built.
输出格式
Output a single integer, the answer.
样例 1
输入:
6
1 2 3 4 5 6
输出:
8
样例 2
输入:
3
-3 -2 -1
输出:
0
样例 3
输入:
4
8 8 1 1
输出:
8
样例说明
The answers are 8, 0 and 8. With negative values, building no group gives 0 instead of being forced to build one.