#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
int n,q; long long a[N];
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin>>n>>q;
for(int i = 1;i <= n;++i) cin>>a[i];
while(q--){
int l,r,k; cin>>l>>r>>k;
long long temp = 0,temp2 = a[l];
for (int i = l + 1; i <= r; i++){
if (a[i] >= temp2) temp2 = a[i];
else temp = max(temp, temp2 + a[i]);
}
cout<<(temp <= k ? 1 : 0)<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
464 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
464 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 |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
508 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
8 ms |
504 KB |
Output is correct |
16 |
Correct |
7 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3067 ms |
8304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1415 ms |
2948 KB |
Output is correct |
2 |
Execution timed out |
3062 ms |
2924 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
464 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 |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
508 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
8 ms |
504 KB |
Output is correct |
16 |
Correct |
7 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
360 KB |
Output is correct |
19 |
Execution timed out |
3011 ms |
3200 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
464 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 |
348 KB |
Output is correct |
13 |
Correct |
4 ms |
508 KB |
Output is correct |
14 |
Correct |
6 ms |
348 KB |
Output is correct |
15 |
Correct |
8 ms |
504 KB |
Output is correct |
16 |
Correct |
7 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
360 KB |
Output is correct |
19 |
Execution timed out |
3067 ms |
8304 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |