Steve_JTH @ 2022-07-23 13:04:30
#include <cstdio>
int main(){
int n, m, a[2000001];
scanf("%d%d",&n,&m);
for (int i = 1; i <= n; i++){
scanf("%d",&a[i]);
}
int head = 0, tail = 0, q[2000001] = {0};
for (int i = 0; i <= n; i++){
while (head <= tail && a[q[tail ]] >= a[i]){
tail--;
}
q[++tail] = i;
while (q[head ] <= i - m){
head++;
}
printf("%d\n",a[q[head]]);
}
return 0;
}
by Steve_JTH @ 2022-07-23 13:04:40
求助
by Steve_JTH @ 2022-07-23 13:05:23
样例也过不了
by Y100 @ 2022-07-23 13:31:40
你的 a 数组是从a[1]开始存的,并且没有初始化,但是后来的i是从0开始的,即访问了a[0] (大概)
by Steve_JTH @ 2022-07-24 09:05:06
@yunheng1024 栓Q
by Steve_JTH @ 2022-07-24 09:12:04
@yunheng1024 过了过了