救救我
  • 板块灌水区
  • 楼主2011hym
  • 当前回复2
  • 已保存回复3
  • 发布时间2024/10/20 12:33
  • 上次更新2024/10/20 14:35:36
查看原帖
救救我
1114719
2011hym楼主2024/10/20 12:33

为什么T{\color{red}{\text{T}}}了后三个点 \dots

题目链接\text{题目链接}

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int w=1e5+5;
int f[w][18],q,n;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
signed main(){
	cin.tie(0) -> ios::sync_with_stdio(0);
	n=read(),q=read();
	for(int i=1;i<=n;i++){
		f[i][0]=read();
	}
	for(int j=1;j<=19;j++){
		for(int i=1;i+(1<<j)-1<=n;i++){
			f[i][j]=max(f[i][j-1],f[i+(1<<(j-1))][j-1]);
		}
	}
	while(q--){
		int l,r;
		l=read(),r=read();
		int len=log2(r-l+1);
		cout<<max(f[l][len],f[r-(1<<len)+1][len])<<endl;
	}
	return 0;
}
2024/10/20 12:33
加载中...