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;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n;
cin >> n;
vector<ll> a(n);
for(ll &i : a) cin >> i;
ll q;
cin >> q;
while(q--){
ll ty;
cin >> ty;
if(ty==1){
ll x,y;
cin >> x >> y;
a[x-1] = y;
}else{
ll l,r;
cin >> l >> r;
l--;r--;
ll ans = 0;
for(ll i = l;i<=r;i++){
ll L = i-1,R=i+1;
ll cur = a[i];
while(true){
if (L>=l&&a[L]<=cur) cur += a[L--];
else if(R<=r&&a[R]<=cur) cur += a[R++];
else break;
}
ans += L==l-1&&R==r+1;
}
cout << ans << "\n";
}
}
}
# | 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... |