//Dedicated to my love, ivaziva
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
while (q--) {
int l, r, k;
cin >> l >> r >> k, l--, r--;
int ans = 0;
for (int i = l; i <= r; i++) {
for (int j = i - 1; j >= l; j--) {
if (a[j] > a[i]) {
ans = max(ans, a[i] + a[j]);
}
}
}
cout << (ans <= k ? '1' : '0') << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
16 ms |
472 KB |
Output is correct |
7 |
Correct |
17 ms |
344 KB |
Output is correct |
8 |
Correct |
52 ms |
448 KB |
Output is correct |
9 |
Correct |
13 ms |
348 KB |
Output is correct |
10 |
Correct |
33 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
16 ms |
472 KB |
Output is correct |
7 |
Correct |
17 ms |
344 KB |
Output is correct |
8 |
Correct |
52 ms |
448 KB |
Output is correct |
9 |
Correct |
13 ms |
348 KB |
Output is correct |
10 |
Correct |
33 ms |
348 KB |
Output is correct |
11 |
Correct |
750 ms |
492 KB |
Output is correct |
12 |
Execution timed out |
3073 ms |
348 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3067 ms |
4188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3054 ms |
856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
16 ms |
472 KB |
Output is correct |
7 |
Correct |
17 ms |
344 KB |
Output is correct |
8 |
Correct |
52 ms |
448 KB |
Output is correct |
9 |
Correct |
13 ms |
348 KB |
Output is correct |
10 |
Correct |
33 ms |
348 KB |
Output is correct |
11 |
Correct |
750 ms |
492 KB |
Output is correct |
12 |
Execution timed out |
3073 ms |
348 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
456 KB |
Output is correct |
6 |
Correct |
16 ms |
472 KB |
Output is correct |
7 |
Correct |
17 ms |
344 KB |
Output is correct |
8 |
Correct |
52 ms |
448 KB |
Output is correct |
9 |
Correct |
13 ms |
348 KB |
Output is correct |
10 |
Correct |
33 ms |
348 KB |
Output is correct |
11 |
Correct |
750 ms |
492 KB |
Output is correct |
12 |
Execution timed out |
3073 ms |
348 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |