CF1486D Max Median

题目描述

给定一个长度为 $n$ 的序列 $a$,求所有长度 $\ge k$ 的连续子序列中,中位数的最大值。定义中位数是一个长度为 $x$ 的序列升序排序后的第 $\left\lfloor\frac{x+1}{2}\right\rfloor$ 位的值。

输入格式

第一行是 $n$,$k$; 接下来一行为 $a_1,a_2,\cdots,a_n$。

输出格式

一行,为最大的中位数。 #### 数据规模与约定 $1\le n, k\le 2\times 10^5$,$1\le a_i\le n$。

说明/提示

In the first example all the possible subarrays are $ [1..3] $ , $ [1..4] $ , $ [1..5] $ , $ [2..4] $ , $ [2..5] $ and $ [3..5] $ and the median for all of them is $ 2 $ , so the maximum possible median is $ 2 $ too. In the second example $ median([3..4]) = 3 $ .