답안 #335857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335857 2020-12-14T07:01:57 Z amunduzbaev Red-blue table (IZhO19_stones) C++14
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define int long long
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 5005;
ll n, m;
ll a[N], def[N];

vector<int>tree;
void build(int lx, int rx, int x){
	if(lx == rx){
		tree[x] = a[lx];
		return;
	}
	int m = (lx + rx)/2;
	build(lx, m, x*2);
	build(m+1, rx, x*2+1);
}

int find(int l,int r, int lx, int rx, int x){
	if(lx > r || rx < l){
		return 0;
	}
	if(lx >= l && rx <= r){
		return tree[x];
	}
	int m = (lx + rx)/2;
	int mx = find(l, r, lx, m, x*2);
	mx = max(mx, find(l, r, m+1, rx, x*2+1));
	return mx;
}

void solve(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		def[i] = a[i];
	}
	int s = 2;
	while(s < n) s<<=1;
	tree.assign(2*s, 0);
	build(1, s, 1);
	
	while(m--){
		ll l, r, k;
		cin>>l>>r>>k;
		int ans = 0;
		for(int i=l; i<=r; i++){
			int mx = find(l, i-1, 1, s, 1);
			if(mx > a[i])
				ans = max(ans, mx + a[i]);
		}
		if(ans > k) cout<<0<<'\n';
		else cout<<1<<'\n';
	}
	return;
}

signed main(){
	fastios
	int t = 1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Wrong answer
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Wrong answer
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -