You are given an array of positive integers. Define a "window" to be a subarray of a fixed size of exactly
elements.
Initially, the window starts off at the leftmost position. Then, it slides right by one index, such that exactly one new element is included in the window and the leftmost element of the window is no longer included within the window. This continues until the window can no longer slide right. For each of these windows, your task is to output the minimum element within the window.
More specifically, you are to output the minimum element across all subarrays of size , from the leftmost subarray to the rightmost.
Input Specification
The first line will consist of two spaced single integer and
.
The next line consists of spaced integers, where the
-th integer is
.
Output Specification
For each of the windows of size , output its minimum element on its own line.
Sample Input 1
5 3
1 3 2 5 4
Output for Sample Input 1
1
2
2
Explanation of Output for Sample Input 1
The array given is . The windows slides across as follows:
minimum of
is
minimum of
is
minimum of
is
Sample Input 2
6 2
2 3 1 4 5 3
Output for Sample Input 2
2
1
1
4
3
Explanation of Output for Sample Input 2
The window slides as follows:
Comments