#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
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(ans>k){
break;
}
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 << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
316 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 |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
316 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 |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
308 KB |
Output is correct |
12 |
Correct |
2 ms |
456 KB |
Output is correct |
13 |
Correct |
2 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
13 ms |
460 KB |
Output is correct |
17 |
Correct |
17 ms |
456 KB |
Output is correct |
18 |
Correct |
12 ms |
436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
437 ms |
22512 KB |
Output is correct |
2 |
Correct |
476 ms |
22772 KB |
Output is correct |
3 |
Correct |
442 ms |
22600 KB |
Output is correct |
4 |
Correct |
436 ms |
22684 KB |
Output is correct |
5 |
Execution timed out |
3087 ms |
16104 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
751 ms |
3160 KB |
Output is correct |
2 |
Correct |
2400 ms |
3212 KB |
Output is correct |
3 |
Execution timed out |
3049 ms |
2784 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
316 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 |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
308 KB |
Output is correct |
12 |
Correct |
2 ms |
456 KB |
Output is correct |
13 |
Correct |
2 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
13 ms |
460 KB |
Output is correct |
17 |
Correct |
17 ms |
456 KB |
Output is correct |
18 |
Correct |
12 ms |
436 KB |
Output is correct |
19 |
Correct |
2753 ms |
8968 KB |
Output is correct |
20 |
Correct |
2852 ms |
9184 KB |
Output is correct |
21 |
Execution timed out |
3072 ms |
5784 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
316 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 |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
308 KB |
Output is correct |
12 |
Correct |
2 ms |
456 KB |
Output is correct |
13 |
Correct |
2 ms |
460 KB |
Output is correct |
14 |
Correct |
3 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
460 KB |
Output is correct |
16 |
Correct |
13 ms |
460 KB |
Output is correct |
17 |
Correct |
17 ms |
456 KB |
Output is correct |
18 |
Correct |
12 ms |
436 KB |
Output is correct |
19 |
Correct |
437 ms |
22512 KB |
Output is correct |
20 |
Correct |
476 ms |
22772 KB |
Output is correct |
21 |
Correct |
442 ms |
22600 KB |
Output is correct |
22 |
Correct |
436 ms |
22684 KB |
Output is correct |
23 |
Execution timed out |
3087 ms |
16104 KB |
Time limit exceeded |