Last active
June 29, 2018 08:10
-
-
Save sadmiko/99c90abd95b762dd83116d9190018c9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
const long long int inf=9999999999999999; | |
int main(){ | |
int n;cin>>n; | |
vector<long long int>a(n); | |
vector<long long int>b(n); | |
for(int i=0;i<n;++i){ | |
cin>>a[i]; | |
b[0]=a[0]; | |
if(i!=0)b[i]=b[i-1]+a[i]; | |
} | |
long long int ans=inf; | |
for(int i=0;i<n-1;i++){ | |
long long int s_ans=abs(b[i]-(b[n-1]-b[i])); | |
ans=min(ans,s_ans); | |
} | |
cout<<ans<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment