제출 #1004906

#제출 시각아이디문제언어결과실행 시간메모리
1004906ByeWorldHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
3058 ms47468 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 1e6+10;
const ll INF = 1e18+10;
const int LOG = 29;
const int MOD = 1e9+7;
const int SQRT = 450;
const vector<int> NOL = {};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};

int n, m, q;
int a[MAXN];


signed main(){
	// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for(int i=1; i<=n; i++) cin >> a[i];
	
	for(int xx=1; xx<=m; xx++){
		int l, r, x; cin >> l >> r >> x;
		set <int> s;
		int MX = 0;
		for(int i=r; i>=l; i--){
			auto it = s.lower_bound(a[i]);
			if(it != s.begin()){
				it--; MX = max(MX, a[i] + *it);
			}
			s.insert(a[i]);
		}
		if(MX <= x) cout << "1\n";
		else cout << "0\n";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...