CF626E.Simple Skewness

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of nn (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.

输入格式

The first line of the input contains a single integer nn ( 1<=n<=200 0001<=n<=200\ 000 ) — the number of elements in the list.

The second line contains nn integers xix_{i} ( 0<=xi<=10000000<=x_{i}<=1000000 ) — the ii th element of the list.

输出格式

In the first line, print a single integer kk — the size of the subset.

In the second line, print kk integers — the elements of the subset in any order.

If there are multiple optimal subsets, print any.

输入输出样例

  • 输入#1

    4
    1 2 3 12
    

    输出#1

    3
    1 2 12 
    
  • 输入#2

    4
    1 1 2 2
    

    输出#2

    3
    1 1 2 
    
  • 输入#3

    2
    1 2
    

    输出#3

    2
    1 2
    

说明/提示

In the first case, the optimal subset is , which has mean 55 , median 22 , and simple skewness of 52=35-2=3 .

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

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

首页