LogiQuest

201. Sliding Window Minimum

MediumDeque

Print the minimum of every window of k consecutive elements.

Input format

Line 1: n k Line 2: n integers

Output format

n − k + 1 minimums.

Example 1

Input

8 3
1 3 -1 -3 5 3 6 7

Output

-1 -3 -3 -3 3 3

Example 2

Input

1 1
4

Output

4

Constraints

1 ≤ k ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…