

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
AtCoder 公園の敷地は東西南北に広がる のマス目からなっており、北から 番目かつ西から 番目のマスの高さは で与えられます。
公園の管理者である高橋君はここに の区画の池を作る事にしました。
池を作るにあたって、高橋君は AtCoder 公園の敷地内に完全に含まれる の区画であってその区画に含まれるマスの高さの中央値が最も低いようなものを選ぼうと考えました。そのような区画のマスの高さの中央値を求めてください。
ここで、 の区画に含まれるマスの高さの中央値とはその区画に含まれる 個のマスのうち 番目に高いマスの高さを指します。また、 は 以下の最大の整数を表します。
制約
- 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
3 2 1 7 0 5 8 11 10 4 2
出力例 1Copy
4
北から 番目で西から 番目のマスを で表すとして、
池の候補となる の区画は、 の つです。
のとき、各区画に含まれるマスの高さの中央値は各区画に含まれるマスのうち 番目に高いマスの高さとなるので、それぞれの区画の中央値は , , , であり、このうち最小である を出力します。
入力例 2Copy
3 3 1 2 3 4 5 6 7 8 9
出力例 2Copy
5
Score : points
Problem Statement
The land of a park AtCoder is an grid with east-west rows and north-south columns. The height of the square at the -th row from the north and -th column from the west is given as .
Takahashi, the manager, has decided to build a square pond occupying squares in this park.
To do this, he wants to choose a square section of squares completely within the park whose median of the heights of the squares is the lowest. Find the median of the heights of the squares in such a section.
Here, the median of the heights of the squares in a section is the height of the -th highest square among the squares in the section, where is the greatest integer not exceeding .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
3 2 1 7 0 5 8 11 10 4 2
Sample Output 1Copy
4
Let denote the square at the -th row from the north and -th column from the west.
We have four candidates for the section occupied by the pond: .
When , since , the median of the heights of the squares in a section is the height of the -rd highest square, which is , , , for the candidates above, respectively. We should print the lowest of these: .
Sample Input 2Copy
3 3 1 2 3 4 5 6 7 8 9
Sample Output 2Copy
5