#include <bits/stdc++.h>
using namespace std;
int main(){
int n, q, l, r, x;
cin >> n >> q;
pair<int, int> a[n + 1];
int aa[n + 1];
map<int, int>mp;
mp[-1] = 0;
aa[0] = -1;
for(int i = 1; i <= n; i++){
cin >> a[i].first;
a[i].second = i;
aa[i] = a[i].first;
}
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
mp[a[i].second] = i;
}
while(q--){
cin >> l >> r >> x;
int mx = -1, last = -1, mn = INT_MAX;
for(int i = l; i <= r; i++){
if(mp[last] > mp[aa[i]]){
mx = max({mx, aa[i], a[mp[last]].first});
}
last = max({last, mp[aa[i]]});
mn = min(mn, mp[aa[i]]);
}
cout << (mn + mx <= x ? 1 : 0) << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3082 ms |
101596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3097 ms |
6064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |