#P1440. 求m区间内的最小值

求m区间内的最小值

Description

Given a sequence with nn terms, for each term, find the minimum within the interval consisting of the previous mm numbers before it. If there are fewer than mm previous numbers, start from the first number. If there are no previous numbers, output 00.

Input Format

The first line contains two integers nn, mm.

The second line contains nn positive integers, which form the given sequence aia_i.

Output Format

Output nn lines, one integer per line. The ii-th number is the minimum among the mm numbers before aia_i in the sequence.

6 2
7 8 1 4 3 2

0
7
7
1
1
3 

Hint

For 100%100\% of the testdata, it is guaranteed that 1mn2×1061 \le m \le n \le 2\times 10^6, 1ai3×1071 \le a_i \le 3\times 10^7.

Translated by ChatGPT 5