CF626E.Simple Skewness
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
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 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.
定义一个数字集合的简单偏度(simple skewness)为该集合的均值减去其中位数。你被给定一个包含 $ n $ 个(不一定互异)整数的列表。请找出具有最大简单偏度的非空子集(允许重复)。
一个集合的均值是其所有元素的平均值;其中位数是将所有元素按升序排列后位于中间位置的元素;若元素个数为偶数,则中位数为中间两个元素的平均值。
输入格式
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.
输入的第一行包含一个整数 n(1≤n≤200000)—— 表示列表中元素的个数。
第二行包含 n 个整数 xi(0≤xi≤1000000)—— 表示列表的第 i 个元素。
输出格式
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.
第一行输出一个整数 k —— 子集的大小。
第二行输出 k 个整数 —— 子集中的元素,顺序任意。
若存在多个最优子集,输出任意一个即可。
输入输出样例
输入#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 5, median 2, and simple skewness of 5 - 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 0.
第一种情况,最优子集为
,其均值为 5,中位数为 2,简单偏度为 5−2=3。
第二种情况,最优子集为
。注意:元素可重复。
最后一种情况,任意子集的中位数与均值均相同,因此所有子集的简单偏度均为 0。
输入解题思路,AI测评打分。不知道怎么写?