_Geburah @ 2024-06-28 18:15:13
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,m;
int s[2000010];
int main()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)
scanf("%d",&s[i]);
cout<<"0\n";
int minx=s[1];
cout<<minx<<"\n";
for(int i=3;i<=n;i++)
{
if(m>=i-1)
{
if(s[i-1]<=minx)minx=s[i-1];
}
else
{
if(minx==s[i-m-1])
{
minx=2147483646;
for(int j=i-m;j<=i-1;j++)
{
if(s[j]<=minx)minx=s[j];
}
}
else
{
if(s[i-1]<=minx)minx=s[i-1];
}
}
cout<<minx<<"\n";
}
return 0;
}