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;
long long mod=1e9+7;
long long n,a[1000006];
int main()
{
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
long long l=0,r=n-1,lsum=a[0],rsum=a[n-1],ans=0;
while(l<r)
{
if(lsum<rsum)
{
l++;
lsum+=a[l];
ans++;
}
else if(lsum>rsum)
{
r--;
rsum+=a[r];
ans++;
}
else
{
lsum=a[l+1];
rsum=a[r-1];
l++;
r--;
}
}
cout<<ans;
}
# | 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... |
# | 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... |