# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029657 | mansur | Super Dango Maker (JOI22_dango3) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 << ' ';
}
}
}