Math_Miss @ 2023-12-30 18:05:43
#include <iostream>
using namespace std;
const int N=200001;
const int logN=25;
int a[N],n,m,f[N][logN];
int log[N];
void loger(){
log[1]=0;
int step=1;
for(int i=1;i<=N;i++){
if(i==2*log[step]){
step++;
log[i]=log[i-1]+1;
}
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
loger();
for(int i=1;i<=n;i++){
f[i][0]=a[i];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=log[n];j++){
f[i][j]=min(f[i][j-1],f[i+(1<<j-1)][j-1]);
}
}
int k;
cout<<0<<endl;
for(int i=1;i<=m-1;i++){
int l=1,r=i;
k=log[r-l+1];
cout<<min(f[l][k],f[r-(1<<k)+1][k])<<endl;
}
for(int i=m;i<=n-1;i++){
int l=i-m+1,r=i;
k=log[r-l+1];
cout<<min(f[l][k],f[r-(1<<k)+1][k])<<endl;
}
return 0;
}
5WA5RE了,求调
by wzzzh @ 2023-12-30 18:22:05
loger
函数有锅 @main888