blob: 24dadf990200cfcf605b45045954cf1527755de8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N = 0;
scanf("%d", &N);
vector<long> m;
long temp = 0;
for (int i = 0; i < N; i++) {
scanf("%ld", &temp);
m.push_back(temp);
}
int l = 0, r = N - 1;
long lalc = 0, ralc = 0;
long tot = 0;
while (l <= r) {
if (lalc < ralc)
lalc += m[l++];
else
ralc += m[r--];
if (lalc == ralc) {
tot = (l - 1 - r) + N;
}
}
printf("%ld", tot);
}
|