# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43362 | 2018-03-14T18:02:34 Z | Hassoony | Nizin (COCI16_nizin) | C++14 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MX=1e6+9; int n,a[MX]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d",&a[i]); int p1=0,p2=n-1,ans=0; ll sum1=0,sum2=0; while(p1<p2){ if(sum1+a[p1]-sum2-a[p2]==0){ ++p1; --p2; sum1=sum2=0; continue; } if(sum1+a[p1]<sum2+a[p2]){ sum1+=a[p1++]; ans++; } else{ sum2+=a[p2--]; ans++; } } if(n==1){ cout<<0<<endl; return 0; } if(sum!=0)ans++; cout<<ans<<endl; }