atcoder#ABC236E. [ABC236E] Average and Median
[ABC236E] Average and Median
Score : points
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 .
6
2 1 2 1 1 10
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.
7
3 1 4 1 5 9 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.