有没有julao能帮忙看一看
  • 板块P2251 质量检测
  • 楼主thrX
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/11/5 16:41
  • 上次更新2023/11/5 18:32:16
查看原帖
有没有julao能帮忙看一看
710862
thrX楼主2023/11/5 16:41

这是我的CODE:

#include<bits/stdc++.h>
using namespace std;
int n,m,st[30][1000000];
int find(int l,int r){
	int p=(r-l+1);
	int k=log2(p);
	return min(st[k][l],st[k][r-(1<<k)+1]);
}
int main(){
	
	cin>>n>>m;
	for(int i=0;i<30;i++){
		for(int j=0;j<=n;j++)st[i][j]=INT_MAX;
	}
	for(int i=1;i<=n;i++){
		cin>>st[0][i];
	}
	int cnt=1;
	for(int i=1;i<=log2(n);i++){
		cnt*=2;
		for(int j=1;j<=n-cnt+1;j++){
			for(int k=0;k<=i;k++){
				st[i][j]=min(st[i][j],st[i-1][j+k]);
			}
		}
	}
//	cnt=1;
//	for(int i=1;i<=log2(n);i++){
//		cnt*=2;
//		for(int j=1;j<=n-cnt+1;j++){
//			cout<<st[i][j]<<' ';
//		}
//		cout<<'\n';
//	}
	for(int i=1;i<=n-m+1;i++){
		cout<<find(i,i+m-1)<<'\n';
	}
	
	return 0;
}

附上这个:

2023/11/5 16:41
加载中...