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>
#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 F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using LL = long long;
using pii = pair<int, int>;
const int MAXN = 100010;
int a[MAXN];
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
// =^-w-^=
int n; cin >> n;
For(i, 1, n) cin >> a[i];
int q; cin >> q;
assert(max(n, q) <= 500);
while(q--) {
int op; cin >> op;
int L, R; cin >> L >> R;
if(op == 1) {
a[L] = R;
continue;
}
int ans = 0;
For(s, L, R) {
int l, r; l = r = s;
int sum = a[s];
bool upd = true;
while(upd) {
upd = false;
if(l > L && sum >= a[l - 1]) {
l--;
sum += a[l];
upd = true;
} else if(r < R && sum >= a[r + 1]) {
r++;
sum += a[r];
upd = true;
}
}
if(l == L && r == R) ans++;
}
cout << ans << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |