#include<bits/stdc++.h>
using namespace std;
#define rall(s) s.rbegin() s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a[n + 1];
for (int i= 1; i <= n; i++) cin >> a[i];
int q;
cin >> q;
while (q--) {
int tp;
cin >> tp;
if (tp == 1) {
int x, y;
cin >> x >> y;
a[x] = y;
}else {
int l, r;
cin >> l >> r;
int ans = 0;
for (int i = l; i <= r; i++) {
ll sum = a[i];
int tl = i - 1, tr = i + 1, ok = 1;
while (tl >= l || tr <= r) {
if (tl >= l && sum >= a[tl]) {
sum += a[tl];
tl--;
continue;
}
if (tr <= r && sum >= a[tr]) {
sum += a[tr];
tr++;
continue;
}
ok = 0;
break;
}
ans += ok;
}
cout << ans << ' ';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
468 KB |
Output is correct |
11 |
Correct |
10 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
23 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
480 ms |
1400 KB |
Output is correct |
3 |
Correct |
51 ms |
1116 KB |
Output is correct |
4 |
Correct |
443 ms |
1368 KB |
Output is correct |
5 |
Correct |
52 ms |
1116 KB |
Output is correct |
6 |
Execution timed out |
4064 ms |
1628 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
468 KB |
Output is correct |
11 |
Correct |
10 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
23 ms |
472 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
480 ms |
1400 KB |
Output is correct |
23 |
Correct |
51 ms |
1116 KB |
Output is correct |
24 |
Correct |
443 ms |
1368 KB |
Output is correct |
25 |
Correct |
52 ms |
1116 KB |
Output is correct |
26 |
Execution timed out |
4064 ms |
1628 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
480 ms |
1400 KB |
Output is correct |
3 |
Correct |
51 ms |
1116 KB |
Output is correct |
4 |
Correct |
443 ms |
1368 KB |
Output is correct |
5 |
Correct |
52 ms |
1116 KB |
Output is correct |
6 |
Execution timed out |
4064 ms |
1628 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
480 ms |
1400 KB |
Output is correct |
3 |
Correct |
51 ms |
1116 KB |
Output is correct |
4 |
Correct |
443 ms |
1368 KB |
Output is correct |
5 |
Correct |
52 ms |
1116 KB |
Output is correct |
6 |
Execution timed out |
4064 ms |
1628 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
348 KB |
Output is correct |
10 |
Correct |
4 ms |
468 KB |
Output is correct |
11 |
Correct |
10 ms |
468 KB |
Output is correct |
12 |
Correct |
2 ms |
600 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
6 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
3 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
23 ms |
472 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
480 ms |
1400 KB |
Output is correct |
23 |
Correct |
51 ms |
1116 KB |
Output is correct |
24 |
Correct |
443 ms |
1368 KB |
Output is correct |
25 |
Correct |
52 ms |
1116 KB |
Output is correct |
26 |
Execution timed out |
4064 ms |
1628 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |