#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
const int N = 2e6 + 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[1] =0 ;
for(int i= 1 ; i <= n; i++){
cin>> w[i];
if(i > 1 ) {
p[i] = p[i - 1];
if(w[i]>= w[i-1])p[i]++;
}
if(w[i]< mx2) {
mx2 = max(mx2 , w[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]]==r[i]-l[i])cout << 1 << nn
else cout << 0 << nn
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
604 KB |
Output is correct |
15 |
Correct |
8 ms |
800 KB |
Output is correct |
16 |
Correct |
17 ms |
600 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
13 ms |
732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
360 ms |
41356 KB |
Output is correct |
2 |
Correct |
396 ms |
74368 KB |
Output is correct |
3 |
Correct |
399 ms |
74092 KB |
Output is correct |
4 |
Correct |
391 ms |
74236 KB |
Output is correct |
5 |
Correct |
419 ms |
74640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
604 KB |
Output is correct |
15 |
Correct |
8 ms |
800 KB |
Output is correct |
16 |
Correct |
17 ms |
600 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
13 ms |
732 KB |
Output is correct |
19 |
Incorrect |
82 ms |
15028 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
5 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
604 KB |
Output is correct |
15 |
Correct |
8 ms |
800 KB |
Output is correct |
16 |
Correct |
17 ms |
600 KB |
Output is correct |
17 |
Correct |
10 ms |
604 KB |
Output is correct |
18 |
Correct |
13 ms |
732 KB |
Output is correct |
19 |
Correct |
360 ms |
41356 KB |
Output is correct |
20 |
Correct |
396 ms |
74368 KB |
Output is correct |
21 |
Correct |
399 ms |
74092 KB |
Output is correct |
22 |
Correct |
391 ms |
74236 KB |
Output is correct |
23 |
Correct |
419 ms |
74640 KB |
Output is correct |
24 |
Incorrect |
27 ms |
4444 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |