hanzhongtlx @ 2019-12-28 21:43:29
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<stack>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
int a[1000005],q1[1000005],q2[1000005];
int num[1000005];
void find_min()
{
int h=0;
int t=1;
cout<<"0\n";
for(int i=1;i<=n-1;i++)
{
while(h>=t&&q1[h]>=a[i]) h--;
h++;
q1[h]=a[i];
num[h]=i;
while(num[t]<=i-k) t++;
cout<<q1[t]<<"\n";
}
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
find_min();
return 0;
}