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;
int x,y,n,sum1,sum2,ans;
int main()
{
cin>>n;
int a[n];
for(int i=0; i<n; i++)
cin>>a[i];
x=0;
y=n-1;
sum1=0;
sum2=0;
while(y>x)
{
if(a[y]==a[x])
{
y--;
x++;
sum1=0;
sum2=0;
continue;
}
if(a[y]>a[x])
{
sum1+=a[x];
x++;
sum2+=a[y];
y--;
}
while(sum1!=sum2)
{
if(sum2>sum1)
{
sum1+=a[x];
x++;
}
else
{
sum2+=a[y];
y--;
}
ans++;
}
}
cout<<ans;
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... |
# | 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... |