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>
using namespace std;
const long long N = 1e6 + 10;
int main () {
int n, m;
cin >> n >> m;
long long arr[n];
for(int i = 0;i<n;i++)cin>>arr[i];
int prefix[n+1] = {0};
prefix[1] = 1;
long long MIN = 1e18;
for(int i = 1;i<n;i++){
MIN = min(MIN, arr[i]);
prefix[i+1] = (prefix[i]+(arr[i] >= arr[i-1]));
}
while(m--) {
int l, r, m;
cin >> l >> r >> m;
long long MAX = arr[l-1],ans = 0;
if(m <= MIN) {
cout << (prefix[r]-prefix[l-1] == r-l) << endl;
}
else {
for(int i = l;i<r;i++) {
MAX = max(arr[i],MAX);
if(arr[i] < MAX)
ans = max(ans, MAX+arr[i]);
}
cout << (ans <= m) << endl;}
}
}
# | 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... |