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 ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
using namespace std;
ll n , q;
ll a[100009];
ll gt(ll l , ll r)
{
ll ans = 0;
for(int i = l ; r>=i ; i++)
{
ll l1 = i-1 , r1 = i+1;
bool g = 0;
ll sum = a[i];
while(true)
{
if(l1==l-1&&r1==r+1)
{
g=1;
break;
}
if(l1==l-1)
{
if(sum>=a[r1])
{
sum+=a[r1];
r1++;
}
else
break;
}
else if(r1==r+1)
{
if(sum>=a[l1])
{
sum+=a[l1];
l1--;
}
else
break;
}
else
{
if(a[l1]>a[r1])
{
if(sum>=a[r1])
{
sum+=a[r1];
r1++;
}
else
break;
}
else
{
if(sum>=a[l1])
{
sum+=a[l1];
l1--;
}
else
break;
}
}
}
if(g)
ans++;
}
return ans;
}
int main()
{
d3
cin >> n;
for(int i = 1 ; n>=i ; i++)
cin >> a[i];
cin >> q;
while(q--)
{
ll t;
cin >> t;
if(t==1)
{
ll x , y;
cin >> x >> y;
a[x]=y;
}
else
{
ll l , r;
cin >> l >> r;
ll ans = gt(l,r);
cans
}
}
}
# | 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... |