답안 #1071390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071390 2024-08-23T07:07:13 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 9144 KB
#include <bits/stdc++.h>
#define int long long
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
const int N=1e6+1;
const int inf=1e18;
const int mod=1e9+7;
using namespace std;
int n;
struct edge{
	int mn,mx,ps;
};
vector<int>v;
edge t[4*N];
void build(int n,int tl,int tr){
	if(tl==tr){
		t[n].mx=v[tl];
		t[n].mn=v[tl];
		t[n].ps=tl;
		return;
	}
	int mid=(tl+tr)/2;
	build(n*2,tl,mid);
	build(n*2+1,mid+1,tr);
	t[n].mn=min(t[n*2].mn,t[n*2+1].mn);
	t[n].mx=max(t[n*2].mx,t[n*2+1].mx);
	if(t[n].mx==t[n*2].mx){
		t[n].ps=t[n*2].ps;
	}else{
		t[n].ps=t[n*2+1].ps;
	}
}
pair<int,int> getmx(int n,int tl,int tr,int l,int r){
	if(tr<l||r<tl){
		return {-1,-1};
	}
	if(l<=tl&&tr<=r){
		return {t[n].mx,t[n].ps};
	}
	int mid=(tl+tr)/2;
	pair<int,int> p=getmx(n*2,tl,mid,l,r);
	pair<int,int> o=getmx(n*2+1,mid+1,tr,l,r);
	pair<int,int> ans;
	ans.first=max(p.first,o.first);
	if(ans.first==p.first){
		ans.second=p.second;
	}else{
		ans.second=o.second;
	}
	return ans;
}
int getmn(int n,int tl,int tr,int l,int r){
	if(tr<l||r<tl){
		return inf;
	}
	if(l<=tl&&tr<=r){
		return t[n].mn;
	}
	int mid=(tl+tr)/2;
	return min(getmn(n*2,tl,mid,l,r),getmn(n*2+1,mid+1,tr,l,r));
}
signed main(){
	boost;
	int n,m;
	cin>>n>>m;
	v.push_back(0);
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		v.push_back(x);
	}
	while(m--){
		int l,r,k;
		cin>>l>>r>>k;
		int mx=0;
		int mn=inf;
		for(int i=l;i<=r;i++){
			mx=max(mx,v[i]);
			mn=min(mn,v[i]);
		}
		if(mx+mn<=k){
			cout<<1<<"\n";
		}else{
			cout<<0<<"\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3059 ms 9144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1708 ms 1500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -