atcoder#ARC101B. [ABC107D] Median of Medians
[ABC107D] Median of Medians
Score : points
Problem Statement
We will define the median of a sequence of length , as follows:
- Let be the sequence obtained by sorting in non-decreasing order. Then, the value of the -th element of is the median of . Here, is integer division, rounding down.
For example, the median of is ; the median of is ; the median of is .
Snuke comes up with the following problem.
You are given a sequence of length . For each pair (), let be the median of the contiguous subsequence of . We will list for all pairs to create a new sequence . Find the median of .
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the median of .
3
10 30 20
30
The median of each contiguous subsequence of is as follows:
- The median of is .
- The median of is .
- The median of is .
- The median of is .
- The median of is .
- The median of is .
Thus, and the median of is .
1
10
10
10
5 9 5 9 8 9 3 5 4 3
8