#P8978. 「DTOI-4」中位数
「DTOI-4」中位数
Problem Description
Given an integer sequence of length , you may perform the following operation at most times:
- Choose an interval such that , and replace all numbers in with the median of this interval.
You want to make the minimum value of as large as possible after the operations.
Definition of the median here: for a sequence of length , its median is defined as the -th smallest number in the sequence.
Input Format
The first line contains two integers .
The second line contains integers .
Output Format
Output one line containing the maximum possible value of the minimum element of the sequence after at most operations.
10 2
2 8 3 2 5 7 10 4 9 7
7
30 3
1 0 1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0
31 3
1 0 1 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1
1
Hint
| Score | ||
|---|---|---|
| No special constraints. |
For of the testdata, , , and .
Translated by ChatGPT 5