ETO_ @ 2024-08-11 15:15:36
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[2000006];
int ans[2000006];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
ans[i]=a[i];
}
for(int j=1;(1<<j)<=m;j++){
for(int i=1;i+(1<<j)<=n;i++){
ans[i]=min(ans[i],ans[i+(1<<(j-1))]);
}
}
cout<<0<<endl;
int l,r,t,mi=INT_MAX;
for(int i=2;i<=m;i++){
mi=min(mi,a[i-1]);
cout<<mi<<endl;
}
for(int i=m+1;i<=n;i++){
l=i-m;
r=i-1;
t=log2(r-l+1);
cout<<min(ans[l],ans[r-(1<<t)+1])<<endl;
}
return 0;
}
by SX114514 @ 2024-08-11 15:21:20
用scanf!!!!!!!!!!!!!!!!!
by Scez @ 2024-08-13 07:58:52
@ETO_ 输出用printf