如题
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
inline ll read()
{
ll k = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
k = k * 10 + ch - '0';
ch = getchar();
}
return k * f;
}
const ll m=10000;
ll Pow(ll a,ll b)
{
a%=m;
ll sum=1;
while(b)
{
if(b & 1) sum = sum * a % m;
b >>= 1;
a=a*a%m;
}
return sum;
}
priority_queue<pair<ll,ll> > que;
ll a[2000005];
int main()
{
ll n=read(),k=read();
for(int i=1;i<=n;i++)
{
a[i]=read();
}
for(int i=1;i<=k;i++)que.push(make_pair(a[i],i));
ll l=1,r=k;
while(r<=n)
{
while(que.top().second<l||que.top().second>r)que.pop();
cout<<que.top().first<<'\n';
l++,r++;
if(r<=n)que.push(make_pair(a[r],r));
}
}