#abc236e. E - Average and Median
E - Average and Median
Score : points
问题描述
我们有 张卡片。第 张卡片()上写有一个整数 。
Takahashi 将从这些卡片中选择任意数量的卡片。但是,对于每个 (),至少需要选择第 张和第 张卡片中的其中一张。
找出以下两个值:
- 所选卡片上整数的最大可能平均值
- 所选卡片上整数的最大可能中位数
这里, 个整数的中位数定义为其中第 小的那个数,其中 表示不小于 的最小整数。
以上为通义千问 qwen-max 翻译,仅供参考。
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