Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[200001] = {0}, tot1 = 0;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> a[i];
tot1 += a[i];
}
if(tot1 % 2 == 1)
++tot1;
int i = 0, tot = 0;
while(i < n && tot < tot1 / 2) {
tot += a[i];
++i;
}
cout << i << endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
4
1 3 2 1
1 3 2 1
Output
2
Demonstration
Codeforces Solution-A. Equator-Solution in C, C++, Java, Python,Equator,Codeforces Solution