cswork / OA打开练习工作台

AmazonOA #249

Kth Smallest in Subarray

估计困难可在线判题

考点(AI 标注)单调栈与堆双指针滑窗二分查找

For each contiguous window of length m in the array, from left to right, output its k-th smallest element; equal numbers at different positions each take their own rank. Output in increasing order of window start. The original statement was truncated; this rule is restored from what the original example states explicitly: windows of m=3, the 2nd smallest, and the output order.

输入格式

The first line contains n m k; the second line contains the array. The original text had no numeric bounds; this site uses 1≤k≤m≤n≤100000, −10^9≤element≤10^9.

输出格式

Output n−m+1 integers in order of window start, separated by spaces.

样例 1

输入:

4 3 2
3 1 4 2

输出:

3 2

样例 2

输入:

3 2 2
2 2 1

输出:

2 2

样例 3

输入:

1 1 1
-5

输出:

-5

样例说明

The answers are 3 2, 2 2 and −5. In the second example the two 2s are two separate elements.