cswork / OA打开练习工作台

AmazonOA #290

Optimizing Box Weights

估计简单可在线判题

考点(AI 标注)贪心调度原地数组

Split all items, by identity, into A and B, with each item in exactly one group; different items with the same weight are still separate. You need sum(A)>sum(B). First minimize the number of items in A, then, among the minimum counts, maximize the total weight of A, and output the weights of A in ascending order. B may be empty.

输入格式

The first line contains n and the second line contains the weights. 1≤n≤100000, 1≤arr[i]≤10000.

输出格式

Output the weights of the items in A in ascending order, separated by spaces; a repeated weight is printed once per item.

样例 1

输入:

6
5 3 2 4 1 2

输出:

4 5

样例 2

输入:

5
4 2 5 1 6

输出:

5 6

样例 3

输入:

2
2 2

输出:

2 2

样例说明

The answers are 4 5, 5 6 and 2 2 respectively. In the third example, choosing one item only ties, so both items must go into A.