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 MAX 500005
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define inf (1987654321)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
int n, q;
int arr[100005];
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; ++i) cin >> arr[i];
cin >> q;
while(q--) {
int t, a, b; cin >> t >> a >> b;
if(t == 1) arr[a] = b;
else {
ll cnt = 0;
for(int i = a; i <= b; ++i) {
int sz = arr[i], p = i - 1, q = i + 1;
while(true) {
if(q <= b && arr[q] <= sz) sz += arr[q++];
else if(p >= a && arr[p] <= sz) sz += arr[p--];
else break;
}
if(p == a - 1 && q == b + 1) ++cnt;
}
cout << cnt << '\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... |