wyh0721 @ 2023-07-24 16:46:21
#include <bits/stdc++.h>
using namespace std;
int n,k,logn[2000005]={-1},f[2000005][100];
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>f[i][0];
logn[i]=logn[i/2]+1;
}
for(int j=1;j<=logn[n];j++)
for(int i=1;i<=n-(1<<j)+1;i++)
f[i][j]=min(f[i][j-1],f[i+(1<<(j-1))][j-1]);
for(int i=1;i<=n;i++)
{
int x,y=i-1;
if(i<=k)
x=1;
else
x=y-k+1;
int m=logn[y-x+1];
cout<<min(f[x][m],f[y-(1<<m)+1][m])<<endl;
}
return 0;
}
by ysw0521nb @ 2023-07-24 17:00:14
哥,你这个空间爆了吧,这个题是125MB