제출 #1356750

#제출 시각아이디문제언어결과실행 시간메모리
1356750JohanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
8 / 100
3095 ms5084 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define endl "\n"
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(a) a.begin() , a.end()
const ll INF = 1e9 + 5 ;
signed main() {
  IO ;
  ll n ;
  cin >> n ;
  ll q ;
  cin >> q ;
  vector<ll>a(n + 1) ;
  for(ll i = 1 ; i <= n ; i ++) {
    cin >> a[i] ;
  }
  while(q --) {
    bool ok=1;
    ll l,r,k;
    cin>>l>>r>>k;
    multiset<ll>mst;
    for(ll i=l;i<=r;i++){
      auto it=upper_bound(mst.begin(),mst.end(),a[i]);
      if(it!=mst.end()){
        auto it1=--mst.end();
        if(*it1+a[i]>k){
          ok=0;
        }
      }
      mst.insert(a[i]);
    }
    if(ok) cout<<1<<endl;
    else cout<<0<<endl;
  }
}
#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...