#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> a(n);
for (auto &i : a)
cin >> i;
while (q--) {
int l, r, k;
cin >> l >> r >> k; l--; r--;
set<int> s;
bool tr = true;
for (int i = r; i >= l && tr; i--) {
tr = (s.empty() || a[i] <= *s.begin() || a[i] + *--s.lower_bound(a[i]) <= k);
s.insert(a[i]);
}
cout << tr << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
604 KB |
Output is correct |
13 |
Correct |
6 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
812 KB |
Output is correct |
15 |
Correct |
10 ms |
708 KB |
Output is correct |
16 |
Correct |
773 ms |
600 KB |
Output is correct |
17 |
Correct |
431 ms |
604 KB |
Output is correct |
18 |
Correct |
55 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
411 ms |
30928 KB |
Output is correct |
2 |
Correct |
378 ms |
31040 KB |
Output is correct |
3 |
Correct |
389 ms |
31068 KB |
Output is correct |
4 |
Correct |
381 ms |
31068 KB |
Output is correct |
5 |
Execution timed out |
3098 ms |
56552 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3085 ms |
1616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
604 KB |
Output is correct |
13 |
Correct |
6 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
812 KB |
Output is correct |
15 |
Correct |
10 ms |
708 KB |
Output is correct |
16 |
Correct |
773 ms |
600 KB |
Output is correct |
17 |
Correct |
431 ms |
604 KB |
Output is correct |
18 |
Correct |
55 ms |
348 KB |
Output is correct |
19 |
Execution timed out |
3049 ms |
12120 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
604 KB |
Output is correct |
13 |
Correct |
6 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
812 KB |
Output is correct |
15 |
Correct |
10 ms |
708 KB |
Output is correct |
16 |
Correct |
773 ms |
600 KB |
Output is correct |
17 |
Correct |
431 ms |
604 KB |
Output is correct |
18 |
Correct |
55 ms |
348 KB |
Output is correct |
19 |
Correct |
411 ms |
30928 KB |
Output is correct |
20 |
Correct |
378 ms |
31040 KB |
Output is correct |
21 |
Correct |
389 ms |
31068 KB |
Output is correct |
22 |
Correct |
381 ms |
31068 KB |
Output is correct |
23 |
Execution timed out |
3098 ms |
56552 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |