#include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef complex<double> cmplx;
template <typename T> using minPq = priority_queue<T, vector<T>, greater<T>>;
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define ms(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define fs first
#define sn second
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int) (v).size())
#define lbv(v, x) (lower_bound((v).begin(), (v).end(), x) - (v).begin())
#define ubv(v, x) (upper_bound((v).begin(), (v).end(), x) - (v).begin())
template <typename T> inline void UNIQUE(vector<T> &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
#define FR(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define dbg(x) {cout << #x << ' ' << x << endl;}
#define dbgArr(arr, n) {cout << #arr; FR(_i, n) cout << ' ' << arr[_i]; cout << endl;}
const ll BIG = 1e16;
const int MN = 1e5 + 5;
int n, q;
int arr[MN];
int main(){
boost();
cin >> n;
FR(i, n) cin >> arr[i];
cin >> q;
while(q--){
int type, l, r;
cin >> type >> l >> r;
l--;
if(type == 1) arr[l] = r;
else {
int cnt = 0;
FOR(i, l, r){
int a = i, b = i;
ll sum = arr[i];
while(a > l || b < r-1){
if(a > l && sum >= arr[a-1]) sum += arr[--a];
else if(b < r-1 && sum >= arr[b+1]) sum += arr[++b];
else goto loopEnd;
}
cnt++;
loopEnd:;
}
cout << cnt << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
8 ms |
328 KB |
Output is correct |
10 |
Correct |
6 ms |
212 KB |
Output is correct |
11 |
Correct |
16 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
10 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
212 KB |
Output is correct |
19 |
Correct |
4 ms |
336 KB |
Output is correct |
20 |
Correct |
32 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
527 ms |
1228 KB |
Output is correct |
3 |
Correct |
72 ms |
996 KB |
Output is correct |
4 |
Correct |
488 ms |
1268 KB |
Output is correct |
5 |
Correct |
60 ms |
980 KB |
Output is correct |
6 |
Execution timed out |
4049 ms |
1484 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
8 ms |
328 KB |
Output is correct |
10 |
Correct |
6 ms |
212 KB |
Output is correct |
11 |
Correct |
16 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
10 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
212 KB |
Output is correct |
19 |
Correct |
4 ms |
336 KB |
Output is correct |
20 |
Correct |
32 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
527 ms |
1228 KB |
Output is correct |
23 |
Correct |
72 ms |
996 KB |
Output is correct |
24 |
Correct |
488 ms |
1268 KB |
Output is correct |
25 |
Correct |
60 ms |
980 KB |
Output is correct |
26 |
Execution timed out |
4049 ms |
1484 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
527 ms |
1228 KB |
Output is correct |
3 |
Correct |
72 ms |
996 KB |
Output is correct |
4 |
Correct |
488 ms |
1268 KB |
Output is correct |
5 |
Correct |
60 ms |
980 KB |
Output is correct |
6 |
Execution timed out |
4049 ms |
1484 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
527 ms |
1228 KB |
Output is correct |
3 |
Correct |
72 ms |
996 KB |
Output is correct |
4 |
Correct |
488 ms |
1268 KB |
Output is correct |
5 |
Correct |
60 ms |
980 KB |
Output is correct |
6 |
Execution timed out |
4049 ms |
1484 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
212 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
8 ms |
328 KB |
Output is correct |
10 |
Correct |
6 ms |
212 KB |
Output is correct |
11 |
Correct |
16 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
212 KB |
Output is correct |
16 |
Correct |
10 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
212 KB |
Output is correct |
19 |
Correct |
4 ms |
336 KB |
Output is correct |
20 |
Correct |
32 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
527 ms |
1228 KB |
Output is correct |
23 |
Correct |
72 ms |
996 KB |
Output is correct |
24 |
Correct |
488 ms |
1268 KB |
Output is correct |
25 |
Correct |
60 ms |
980 KB |
Output is correct |
26 |
Execution timed out |
4049 ms |
1484 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |