8VC Venture Cup 2016 - Elimination Round
E
Simple Skewness
Codeforces
2400
原题
← DF →
翻译中…

Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of $*n*$ (not necessarily distinct) integers. Find the non-empty subset (with repetition) with the maximum simple skewness.

翻译中…

The mean of a collection is the average of its elements. The median of a collection is its middle element when all of its elements are sorted, or the average of its two middle elements if it has even size.

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($1 ≤ *n* ≤ 200 000$) — the number of elements in the list.

翻译中…

The second line contains $*n*$ integers $*x*_{*i*}$ ($0 ≤ *x*_{*i*} ≤ 1 000 000$) — the $*i*$th element of the list.

翻译中…

Output

翻译中…

In the first line, print a single integer $*k*$ — the size of the subset.

翻译中…

In the second line, print $*k*$ integers — the elements of the subset in any order.

翻译中…

If there are multiple optimal subsets, print any.

翻译中…

Note

翻译中…

In the first case, the optimal subset is image, which has mean $5$, median $2$, and simple skewness of $5 - 2 = 3$.

翻译中…

In the second case, the optimal subset is image. Note that repetition is allowed.

翻译中…

In the last case, any subset has the same median and mean, so all have simple skewness of $0$.

翻译中…

样例

Input #1
4
1 2 3 12
Output #1
3
1 2 12
InputCopy OutputCopy
Input #2
4
1 1 2 2
Output #2
3
1 1 2
InputCopy OutputCopy
Input #3
2
1 2
Output #3
2
1 2
InputCopy OutputCopy
题目信息
题号
626E
时间限制
3 s
内存限制
256 MB
标签
二分
数学
三分

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。