cswork / OA打开练习工作台

IBMOA #69

Array Subsets (Frontend)

估计简单可在线判题

考点(AI 标注)贪心调度

Split the array by element positions into A and B, keeping duplicate values. It is required that sum(A)>sum(B); first minimize the number of elements in A, then maximize the sum of A for that count, and return A in ascending order. B may be empty.

输入格式

The first line contains n, and the second line contains the array. Full original bounds: 1≤n≤100000, 1≤arr[i]≤100000.

输出格式

Output the number of elements in A on the first line, followed by one integer per line in non-decreasing order, keeping duplicates.

样例 1

输入:

6
5 3 2 4 1 2

输出:

2
4
5

样例 2

输入:

5
4 2 5 1 6

输出:

2
5
6

样例 3

输入:

2
1 1

输出:

2
1
1

样例说明

The outputs of the three public examples are, in order: 2 / 4 / 5; 2 / 5 / 6; 2 / 1 / 1. These answers were verified by independent enumeration or direct simulation.