蒟蒻酱 @ 2020-01-19 21:48:08
就到大佬帮忙看看哪里错了
#include<bits/stdc++.h>
using namespace std;
const int N=2000007;
const int INF=0x3f3f3f;
const int M=10005;
int n,m;
int que[N];
int a[N];
int main(){
while(cin>>n>>m)
{
int head=1;
int tail=0;
for(int i=1;i<n;i++)
cin>>a[i];
cout<<0<<endl;
for(int i=0;i<n-1;i++)
{
while(head<=tail&&a[que[tail]]>=a[i])
tail--;
que[++tail] =i;
while(head<=tail&&i-que[head]>=m)
head++;
cout<<a[que[head]]<<endl;
}
}
return 0;
}