#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vi arr;
int main(){
cin>>n>>m;
for(int i = 0; i < n; i++){
int a;
cin>>a;
arr.pb(a);
}
while(m--){
int l, r, k;
cin>>l>>r>>k;
l--; r--;
// minimum and maximum number that are not in the desired place
vi here;
for(int i = l; i <= r; i++) here.pb(i);
sort(here.begin(), here.end());
int s = 0, e = (int)here.size()-1;
while(s <(int)here.size() && arr[l+s] == here[s]) s++;
while(e >= 0 && arr[r-e] == here[e]) e--;
if(e <= s) cout<<0<<endl;
else{
int maxi = 0, mini = 1e9;
for(int i = s; i <= e; i++){
maxi = max(maxi, arr[i]);
mini = min(mini, arr[i]);
}
if(maxi + mini <= k) cout<<1<<endl;
else cout<<0<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3096 ms |
22096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3051 ms |
2364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |