#include <bits/stdc++.h>
#define ll long long
#define fort(x , y) for(int y = 1 ; y <= x ; y++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define int long long
#define F first
#define S second
using namespace std;
const int N = 1e6 + 5;
const int NN = 1e9 + 7;
int n,m,a[N],k[N],l[N],r[N],s[N],cnt,mx[N];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
}
cnt = 1;
for(int i = 1 ; i < n ; i++){
if(a[i] <= a[i + 1]){
s[i] = cnt;
s[i + 1] = cnt;
}
else{
cnt++;
}
}
for(int j = 1 ; j <= m ; j++){
cin >> l[j] >> r[j] >> k[j];
if(n <= 5000 && m <= 5000){
bool oknt = 0;
for(int i = 1 ; i <= n ; i++){
mx[i] = 0;
}
for(int i = l[j] ; i <= r[j] ; i++){
if(mx[i - 1] > a[i]){
if(mx[i - 1] + a[i] > k[j]){
oknt = 1;
break;
}
}
mx[i] = max(a[i],mx[i - 1]);
}
if(oknt){
cout << 0 << '\n';
}
else{
cout << 1 << '\n';
}
continue;
}
if(l[j] == r[j]){
cout << 1 << '\n';
continue;
}
bool ok = 0;
if(s[l[j]] == s[r[j]] && s[l[j]] != 0){
ok = 1;
}
if(ok){
cout << 1 << '\n';
}
else{
cout << 0 << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
1 ms |
10588 KB |
Output is correct |
9 |
Correct |
1 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
1 ms |
10588 KB |
Output is correct |
9 |
Correct |
1 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
3 ms |
10588 KB |
Output is correct |
12 |
Correct |
4 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
6 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12636 KB |
Output is correct |
16 |
Correct |
17 ms |
12820 KB |
Output is correct |
17 |
Correct |
17 ms |
12636 KB |
Output is correct |
18 |
Correct |
18 ms |
12648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
337 ms |
42972 KB |
Output is correct |
2 |
Correct |
365 ms |
75600 KB |
Output is correct |
3 |
Correct |
368 ms |
75392 KB |
Output is correct |
4 |
Correct |
353 ms |
75448 KB |
Output is correct |
5 |
Correct |
353 ms |
75456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
14936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
1 ms |
10588 KB |
Output is correct |
9 |
Correct |
1 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
3 ms |
10588 KB |
Output is correct |
12 |
Correct |
4 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
6 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12636 KB |
Output is correct |
16 |
Correct |
17 ms |
12820 KB |
Output is correct |
17 |
Correct |
17 ms |
12636 KB |
Output is correct |
18 |
Correct |
18 ms |
12648 KB |
Output is correct |
19 |
Incorrect |
71 ms |
19156 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
10588 KB |
Output is correct |
2 |
Correct |
1 ms |
10588 KB |
Output is correct |
3 |
Correct |
2 ms |
10588 KB |
Output is correct |
4 |
Correct |
2 ms |
10588 KB |
Output is correct |
5 |
Correct |
2 ms |
10584 KB |
Output is correct |
6 |
Correct |
2 ms |
10584 KB |
Output is correct |
7 |
Correct |
2 ms |
10588 KB |
Output is correct |
8 |
Correct |
1 ms |
10588 KB |
Output is correct |
9 |
Correct |
1 ms |
10588 KB |
Output is correct |
10 |
Correct |
2 ms |
10588 KB |
Output is correct |
11 |
Correct |
3 ms |
10588 KB |
Output is correct |
12 |
Correct |
4 ms |
12636 KB |
Output is correct |
13 |
Correct |
4 ms |
12636 KB |
Output is correct |
14 |
Correct |
6 ms |
12636 KB |
Output is correct |
15 |
Correct |
5 ms |
12636 KB |
Output is correct |
16 |
Correct |
17 ms |
12820 KB |
Output is correct |
17 |
Correct |
17 ms |
12636 KB |
Output is correct |
18 |
Correct |
18 ms |
12648 KB |
Output is correct |
19 |
Correct |
337 ms |
42972 KB |
Output is correct |
20 |
Correct |
365 ms |
75600 KB |
Output is correct |
21 |
Correct |
368 ms |
75392 KB |
Output is correct |
22 |
Correct |
353 ms |
75448 KB |
Output is correct |
23 |
Correct |
353 ms |
75456 KB |
Output is correct |
24 |
Incorrect |
29 ms |
14936 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |