#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
const int N = 2e5 + 8 , inf = 1e9+7 ;
int n , m , q ;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin>> n >> q;
int w[n+1] , l[q+1] , r[q+1] , k[q+1] , p[n+1];
int mx1 = max(n , q );
int mx2 =0 ;
p[0] =0 ;
for(int i= 1 ; i <= n; i++){
cin>> w[i];
p[i] = p[i-1];
if(w[i]< mx2){
mx2 = max(mx2 , w[i]);
p[i]++;
}
}
for(int i =1 ; i <= q; i++){
cin>> l[i]>> r[i]>> k[i];
}
if(mx1 <= 5000){
for(int i =1 ; i <= q; i++){
int mx =w[l[i]] , cnt =0 ;
for(int j =l[i]+1 ; j <= r[i] ; j++){
if(w[j]< mx ){
cnt = max(cnt , w[j]+mx);
}
else mx = w[j];
}
if(cnt <= k[i] ){
cout << 1 << nn
}
else cout << 0 << nn
}
}
else{
for(int i =1 ; i <= q ; i++){
if(p[r[i]] - p[l[i] - 1]==0 || l[i]==r[i])cout << 1<< nn
else cout << 0 << nn
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
7 ms |
656 KB |
Output is correct |
15 |
Correct |
7 ms |
648 KB |
Output is correct |
16 |
Correct |
12 ms |
604 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
20 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
310 ms |
41472 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
7 ms |
656 KB |
Output is correct |
15 |
Correct |
7 ms |
648 KB |
Output is correct |
16 |
Correct |
12 ms |
604 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
20 ms |
604 KB |
Output is correct |
19 |
Incorrect |
61 ms |
8528 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
588 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
7 ms |
656 KB |
Output is correct |
15 |
Correct |
7 ms |
648 KB |
Output is correct |
16 |
Correct |
12 ms |
604 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
20 ms |
604 KB |
Output is correct |
19 |
Incorrect |
310 ms |
41472 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |