Beihai_Jiang @ 2024-08-30 21:31:43
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
int n,m;
int q[N],s=1,t;
int ti[N];
int read(){
int x=0;
char ch=getchar();
while(ch<'0' || ch>'9')
ch=getchar();
while(ch>='0' && ch<='9')
x=10*x+ch-'0',ch=getchar();
return x;
}
void write(int x,int opt){
if(x>9)
write(x/10,0);
putchar(x%10+'0');
if(opt==1) putchar('\n');
return;
}
void push(int x,int i){
while(t>=s && q[t]>x)
t--;
q[++t]=x;
ti[t]=i;
}
void pop(int i){
if(i-ti[s]+1>m)
s++;
}
int getmin(){
return q[s];
}
int main(){
n=read(),m=read();
write(0,1);
for(int i=1;i<=n;i++){
int x=read();
push(x,i);
pop(i);
if(i<n)
write(getmin(),1);
}
return 0;
}
by Beihai_Jiang @ 2024-08-31 11:22:27
题目先前数据有误,现已AC,此贴结