PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000407. Trung vị lớn nhất (Max Median)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Trung vị lớn nhất (Max Median)

Max Median

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given integers a1,…,ana_1,\ldots,a_n, define the median of a list of length LL as the element at position ⌊(L+1)/2⌋\lfloor(L+1)/2\rfloor in its nondecreasing ordering, indexed from 1. For example, (1,2,3,4)(1,2,3,4) has median 2. Choose a contiguous segment al,…,ara_l,\ldots,a_r with 1≤l≤r≤n1\le l\le r\le n and r−l+1≥kr-l+1\ge k. Find the greatest possible median.

Input

The first line contains integers n,kn,k. The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Output

Print one integer: the greatest achievable median.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤501\le k\le n\le 50; 1≤ai≤n1\le a_i\le n for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤k≤n≤20001\le k\le n\le 2000; 1≤ai≤n1\le a_i\le n for every 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤k≤n≤2000001\le k\le n\le 200000; 1≤ai≤n1\le a_i\le n for every 1≤i≤n1\le i\le n.

Examples

Input

5 3
1 2 3 2 1

Output

2

Explanation

The segments of length 3 are (1,2,3),(2,3,2),(3,2,1)(1,2,3),(2,3,2),(3,2,1); of length 4, (1,2,3,2),(2,3,2,1)(1,2,3,2),(2,3,2,1); of length 5, the entire list. All six have median 2 after sorting.

Input

4 2
1 2 3 4

Output

3

Explanation

The segment (3,4)(3,4) has median 3. No segment of length at least 2 has median 4 because only one element is 4.

Input

3 2
3 1 3

Output

3

Explanation

Both length-2 segments have median 1, whereas the entire segment sorts to (1,3,3)(1,3,3) and has median 3.