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>
#include <unistd.h>
#include <set>
#define dbg(x) //cout<<#x<<" has a value of: "<<x<<"\n";
typedef long long int lli;
using namespace std;
typedef pair<lli,lli> pii;
int main(){
int n;
cin>>n;
vector<lli> dizi(n);
for (int i = 0; i < n; i++)
{
cin>>dizi[i];
}
int l=0,r=n-1;
int cvb=0;
while(l<=r){
lli ls=dizi[l],rs=0;
l++;
int ctl=1,ctr=0;
dbg(ls);
dbg(rs);
while(ls!=rs){
if(l>r){
dbg(ctl);
dbg(ctr);
cvb+=ctl+ctr-1;
break;
}
while(rs<ls && l<=r){
rs+=dizi[r];
ctr++;
r--;
dbg(rs);
dbg(r);
}
while(ls<rs&&l<=r){
ls+=dizi[l];
ctl++;
l++;
dbg(ls);
dbg(l);
}
if(l>r && ls!=rs){
dbg(ctl);
dbg(ctr);
cvb+=ctl+ctr-1;
break;
}
cvb+=ctl+ctr-2;
}
}
cout<<cvb<<"\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... |
# | 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... |