#abc236e. E - Average and Median
E - Average and Median
Score : points
问题描述
我们有 张卡片。第 张卡片 上写有一个整数 。
高桥将从这些卡片中选择任意数量的卡片。然而,对于每个 ,必须选择第 张或第 张卡片中的至少一张。
需要找到以下两个值:
- 选择的卡片上数字的 最大可能平均值
- 选择的卡片上数字的 最大可能中位数
这里, 个数字的中位数定义为第 小的数字,其中 表示不小于 的最小整数。
约束条件
- 输入中的所有值都是整数。
输入
输入从标准输入以以下格式给出:
输出
输出两行。第一行和第二行应分别包含选择的卡片上数字的 最大可能平均值 和 最大可能中位数。对于平均值,当其与精确答案的相对或绝对误差不超过 时,输出将被视为正确。
示例输入 1
6
2 1 2 1 1 10
示例输出 1
4
2
选择第 张、第 张和第 张卡片,使得所写数字的平均值为 ,这是最大可能的。
选择第 张、第 张、第 张和第 张卡片,使得所写数字的中位数为 ,这是最大可能的。
示例输入 2
7
3 1 4 1 5 9 2
示例输出 2
5.250000000
4
对于平均值,输出可以有一定的误差:例如,输出 仍然被认为是正确的。然而,对于中位数,必须精确打印其值。
以上为kimi 翻译,仅供参考。
Problem Statement
We have cards. The -th card has an integer written on it.
Takahashi will choose any number of cards from these. However, for each , at least one of the -th and -th cards must be chosen.
Find the following values.
- The maximum possible average of the integers written on the chosen cards
- The maximum possible median of the integers written on the chosen cards
Here, the median of the integers is defined to be the -th smallest of them, where is the smallest integer not less than .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print two lines. The first and second lines should contain the maximum possible average and maximum possible median of the integers written on the chosen cards, respectively. For the average, your output will be considered correct when its relative or absolute error from the exact answer is at most .
Sample Input 1
6
2 1 2 1 1 10
Sample Output 1
4
2
Choosing the -nd, -th, and -th cards makes the average of the written integers , which is the maximum possible.
Choosing the -st, -rd, -th, and -th cards makes the median of the written integers , which is the maximum possible.
Sample Input 2
7
3 1 4 1 5 9 2
Sample Output 2
5.250000000
4
For the average, your output may contain some degree of error: for example, the output is still considered correct. For the median, however, the exact value must be printed.
update @ 2024/3/10 10:14:03
相关
在下列比赛中: