#include <bits/stdc++.h>
#define fcc ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sqr(a) (a) * (a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rebgin(), x.rend()
#define pb push_back
#define mp make_pair
#define int long long
#define ff first
#define ss second
#define endl "\n"
using namespace std;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
int a[500009], b[500009];
void solve() {
int n, m, l, r, k;
cin >> n >> m;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
a[0] = 0;
while (m--) {
cin >> l >> r >> k;
int ans = 0, leftmax = 0;
for (int i = l; i <= r; i++) {
if (leftmax > a[i]) {
ans = max(ans, leftmax + a[i]);
}
leftmax = max(leftmax, a[i]);
}
if (ans <= k) {
cout << "1\n";
}
else {
cout << "0\n";
}
}
}
signed main() {
fcc;
int t = 1;
// cin >> t;
while (t--) {
solve();
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
436 KB |
Output is correct |
13 |
Correct |
7 ms |
460 KB |
Output is correct |
14 |
Correct |
12 ms |
460 KB |
Output is correct |
15 |
Correct |
11 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
464 KB |
Output is correct |
17 |
Correct |
15 ms |
416 KB |
Output is correct |
18 |
Correct |
18 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3059 ms |
8140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2626 ms |
1260 KB |
Output is correct |
2 |
Execution timed out |
3021 ms |
1416 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
436 KB |
Output is correct |
13 |
Correct |
7 ms |
460 KB |
Output is correct |
14 |
Correct |
12 ms |
460 KB |
Output is correct |
15 |
Correct |
11 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
464 KB |
Output is correct |
17 |
Correct |
15 ms |
416 KB |
Output is correct |
18 |
Correct |
18 ms |
328 KB |
Output is correct |
19 |
Execution timed out |
3068 ms |
2304 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
324 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
3 ms |
332 KB |
Output is correct |
12 |
Correct |
6 ms |
436 KB |
Output is correct |
13 |
Correct |
7 ms |
460 KB |
Output is correct |
14 |
Correct |
12 ms |
460 KB |
Output is correct |
15 |
Correct |
11 ms |
492 KB |
Output is correct |
16 |
Correct |
19 ms |
464 KB |
Output is correct |
17 |
Correct |
15 ms |
416 KB |
Output is correct |
18 |
Correct |
18 ms |
328 KB |
Output is correct |
19 |
Execution timed out |
3059 ms |
8140 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |