#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, aa[i]);
}
cout << (mn + mx <= x ? 1 : 0) << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3062 ms |
111688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3076 ms |
6732 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 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
2 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |