제출 #493196

#제출 시각아이디문제언어결과실행 시간메모리
493196erkmHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++11
0 / 100
3086 ms4584 KiB
#include<bits/stdc++.h>

#define loop(n) for(int i=0; i<n; i++)
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define p_b push_back
#define l_b lower_bound
#define u_b upper_bound
#define m_p make_pair
#define m_t make_tuple
#define ar array
using namespace std;
	const int M=1e9, mxN=1e5;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    
    int n, m;
    cin>>n>>m;
    int w[n], mn=INT_MAX;
    for(int i=0; i<n; i++){
    	cin>>w[i];
    	mn=min(mn, w[i]);
	}
	
	while(m--){
		int l, r, k;
		cin>>l>>r>>k;
		l--; r--;
		int ans=0;
		
		if(k<mn){
			for(int i=l; i<r; i++){
				if(w[l]>w[l+1]){
					ans=1;
					break;
				}
			}
			ans? cout<<0: cout<<1;
			cout<<'\n';
			continue;
		}
		
		for(int i=l; i<=r; i++){
			for(int j=i+1; j<=r; j++){
				if(w[i]>w[j]){
					ans=max(ans, w[i]+w[j]);
				}
			}
		}
		ans>k? cout<<0: cout<<1;
		cout<<'\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...