DoublePig666 @ 2022-03-21 13:35:47
include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
int a[N],mmin[N][25];
int n,m,l,r;
int v;
void rmq() {
for(int j=1;j<=20;j++) {
for(int i=1;i<=n;i++) {
if(i+(1<<j)-1<=n) {
mmin[i][j]=min(mmin[i][j-1],mmin[i+(1<<(j-1))][j-1]);
}
}
}
}
int checkmmin(int ll,int rr) {
int x=log(rr-ll+1)/log(2);
return (min(mmin[ll][x],mmin[rr+1-(1<<x)][x]));
}
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) {
scanf("%d",&v);
a[i]=v;
mmin[i][0]=v;
}
rmq();
for(int i=1;i<=n;i++) {
printf("%d\n",checkmmin(max(1,i-m),i-1));
}
return 0;
}
by 大眼仔Happy @ 2022-03-21 13:55:14
@DoublePig666 万能头都打错了,没有
by 大眼仔Happy @ 2022-03-21 13:56:38
不确定这道题能不能用ST表啊,因为我用了单调队列。
by DoublePig666 @ 2022-03-24 18:56:42
啊,复制错了!
by DoublePig666 @ 2022-03-24 19:10:00
@大眼仔Happy 谢谢,我在想想