AmazonOA #20
Get Max Throughput
估计中等可在线判题
考点(AI 标注)贪心调度
Split some of the servers into non-overlapping triples; each triple contributes the median of its three throughputs, and leftover servers may go unused. Find the maximum total contribution.
输入格式
The first line contains n (1..100000), and the second line contains n throughputs (1..10⁹).
输出格式
Output a single integer, the answer required by the problem.
样例 1
输入:
5
2 3 4 5 4
输出:
4
样例 2
输入:
2
1 2
输出:
0
样例 3
输入:
6
1 2 3 4 5 6
输出:
8
样例说明
Example 1: five servers can form at most one group; choosing throughputs 3, 4 and 5 gives median 4. Example 2: there are fewer than three servers, so no group can be formed and the answer is 0. Example 3: the servers can be split into [1,5,6] and [2,3,4], with medians 5 and 3, total 8.