This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#define F first
#define S second
#define ALL(a) a.begin() , a.end()
#ifndef ONLINE_JUDGE
#define OK cout << __LINE__ << "| "<< "---------------------------OK-----------------------" << endl;
#define deb(x) cout << __LINE__ << "| "<< #x << " = " << x << endl;
#else
#define OK
#define deb(x)
#endif
typedef long double ld;
typedef long long ll;
using namespace std ;
const ll N = 1e6 + 7 ;
const ll INF = 1e9;
const ll mod = 1e9 + 7 ;
const double eps = 1e-9 ;
const int dx[] = { 0 , 0 , 1 , -1, 1 , -1 , 1 , -1} , dy[] = {1 , -1 , 0 , 0 , 1 , 1, -1 , -1} ;
int n , q, a[N] ;
set<int> st;
void test_solve(int test_index){
cin >> n >> q;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int query = 1; query <= q ; query++){
int l , r , k , ans = 1;
cin >> l >> r >> k;
set<int, greater<>> st;
for(int i = l; i<=r ; i++){
if(st.size() and *st.begin() > a[i] and *st.begin() + a[i] > k){
ans = 0;
break;
}
st.insert(a[i]);
}
cout << ans << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false) ;
cin.tie(0) ;
cout.tie(0);
int test = 1;
//cin >> test ;
for(int i = 1 ; i <= test ; i++){
// cout << "Case " << i << ": " ;
test_solve(i) ;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |