제출 #1143568

#제출 시각아이디문제언어결과실행 시간메모리
1143568crispxxHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
0 / 100
3094 ms50344 KiB
/**
 *    author: a.k
 *    created: idk
**/
#include <bits/stdc++.h>
using namespace std;
 
#define all(x) x.begin(), x.end()
#define int long long
#define nl '\n'

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m; cin >> n >> m;
	
	vector<int> a(n);
	
	for(auto &u : a) cin >> u;
	
	while(m--) {
		int l, r, k; cin >> l >> r >> k;
		l--;
		
		priority_queue<int> pq;
		for(int i = l; i < r; i++) pq.emplace(a[i]);
				
		bool flag = true;
		
		vector<int> used(n);
		
		while(!pq.empty()) {
			int u = pq.top();
			pq.pop();
			
			set<int> st;
			
			for(int i = r - 1; i >= l; i--) {
				if(a[i] == u) {
					auto it = st.upper_bound(k - a[i]);
					if(it != st.end()) flag = false;
					used[i] = true;
					break;
				}
				if(!used[i]) st.emplace(a[i]);
			}
			
			if(!flag) break;
		}
		
		cout << flag << nl;
	}
}
#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...