__erinww @ 2023-06-19 19:38:53
#include <iostream>
using std::min;
const int MAXN = 2e6+10;
struct TREE_NODE{
int l,r;
int value;
} tree[MAXN << 1 +2];
int n,m,a[MAXN];
void BUILD(int p,int l,int r){
tree[p].l = l;tree[p].r = r;
if(l == r){
tree[p].value = a[l];
return ;
}
int mid = l+r >> 1;
BUILD(p << 1,l,mid);
BUILD(p << 1|1,mid+1,r);
tree[p].value = std::min(tree[p << 1].value,tree[p << 1|1].value);
}
int SEARCH(int p,int l,int r){
int x = tree[p].l,y = tree[p].r;
if(x >= l && y <= r) return tree[p].value;
int mid = x+y >> 1;
int step = MAXN << 10;
if(l <= mid) step = min(step,SEARCH(p << 1,l,r));
if(r > mid) step = min(step,SEARCH(p << 1|1,l,r));
return step;
}
signed main(){
scanf("%d%d",&n,&m);
for(int i = 1;i <= n;i ++) scanf("%d",&a[i]);
BUILD(1,1,n);
for(int i = 1;i <= n;i ++){
if(i == 1) printf("0\n");
else if(i-m <= 0) printf("%d\n",SEARCH(1,1,i-1));
else printf("%d\n",SEARCH(1,i-m,i-1));
}
return 0;
}
洛谷CE,dev 上编译了200MB
by Tibrella @ 2023-06-19 19:47:40
您也没交这题啊,还是您开完隐了?
我在洛谷 IDE 测的没问题
by __erinww @ 2023-06-19 19:58:09
@Tibrella
洛谷在线IDE
现在AC了