#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second
//... max1 .... max2
//... max2 .... max1
using namespace std;
void solve(){
int n, m;
cin >> n >> m;
int a[n];
for(int &i: a) cin >> i;
while(m--){
int l, r, k, mx = 0, sum = 0, ok = 1;
cin >> l >> r >> k;
l--, r--;
if(n <= 5000 && m <= 5000){
for(int i = l; i <= r; i++){
sum = max(sum, (a[i] + mx) * (a[i] < mx));
mx = max(mx, a[i]);
}
cout << (sum <= k ? "1\n" : "0\n");
}
else{
for(int i = l; i < r - 1; i++){
if(a[i] > a[i + 1]) ok = 0;
}
cout << (ok ? "1\n" : "0\n");
}
}
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while(t--){
solve();
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
536 KB |
Output is correct |
12 |
Correct |
8 ms |
844 KB |
Output is correct |
13 |
Correct |
9 ms |
604 KB |
Output is correct |
14 |
Correct |
14 ms |
644 KB |
Output is correct |
15 |
Correct |
14 ms |
640 KB |
Output is correct |
16 |
Correct |
26 ms |
592 KB |
Output is correct |
17 |
Correct |
22 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3023 ms |
8512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1622 ms |
1744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
536 KB |
Output is correct |
12 |
Correct |
8 ms |
844 KB |
Output is correct |
13 |
Correct |
9 ms |
604 KB |
Output is correct |
14 |
Correct |
14 ms |
644 KB |
Output is correct |
15 |
Correct |
14 ms |
640 KB |
Output is correct |
16 |
Correct |
26 ms |
592 KB |
Output is correct |
17 |
Correct |
22 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
348 KB |
Output is correct |
19 |
Execution timed out |
3044 ms |
6468 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
3 ms |
536 KB |
Output is correct |
12 |
Correct |
8 ms |
844 KB |
Output is correct |
13 |
Correct |
9 ms |
604 KB |
Output is correct |
14 |
Correct |
14 ms |
644 KB |
Output is correct |
15 |
Correct |
14 ms |
640 KB |
Output is correct |
16 |
Correct |
26 ms |
592 KB |
Output is correct |
17 |
Correct |
22 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
348 KB |
Output is correct |
19 |
Execution timed out |
3023 ms |
8512 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |