Skip to content

Instantly share code, notes, and snippets.

@fredbr
Created May 3, 2018 05:34
Show Gist options
  • Save fredbr/9a64eca693f56df1ea10d030a6f790b6 to your computer and use it in GitHub Desktop.
Save fredbr/9a64eca693f56df1ea10d030a6f790b6 to your computer and use it in GitHub Desktop.
Guerra por Território
//solucao por Davi Gabriel
#include <bits/stdc++.h>
using namespace std;
int v[100100];
int main() {
int n, total = 0, somaI = 0;
cin >> n;
for(int i = 0; i < n; ++i){
cin >> v[i];
total += v[i];
}
for(int i = 0; i < n; ++i){
somaI += v[i];
if(somaI == total/2){
cout << i + 1 << endl;
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment