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;
#define pob pop_back
#define mp make_pair
#define pb push_back
#define mid (l+r)/2
#define test printf("test\n")
#define st first
#define nd second
#define superman ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
ll INF = 1e9;
ll mod = 1e9+7;
double pi = acos(-1);
ll l,k,m,n,ans,r;
vector<ll> nums;
ll leftnum, rightnum;
ll lp,rp;
int main() {
//freopen(".gir","r",stdin);
//freopen(".cik","w",stdout);
cin>>n;
lp = 0; rp = n-1;
nums.resize(n);
for(int i=0; i<n; i++) {
cin>>nums[i];
}
leftnum = nums[0];
rightnum = nums[n-1];
while(lp < rp) {
if(leftnum == rightnum) {
lp++;
rp--;
leftnum = nums[lp];
rightnum = nums[rp];
continue;
}
else {
if(leftnum < rightnum) {
lp++;
leftnum += nums[lp];
}
else {
rp--;
rightnum += nums[rp];
}
ans++;
}
}
cout<<ans<<endl;
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... |