#include <bits/stdc++.h>
using namespace std;
const int md = 1e6 + 10;
int a[md];
int n;
int main() {
//freopen("test.in", "r", stdin);
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
int l = 1, r = n, vL = a[1], vR = a[n], cnt = 0;
while (l <= r) {
if (l == r)
break;
if (vL == vR) {
vL = a[++l];
vR = a[--r];
} else if (vL < vR) {
cnt++;
vL += a[++l];
} else {
cnt++;
vR += a[--r];
}
}
cout << cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
0 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
632 KB |
Output is correct |
2 |
Correct |
10 ms |
1016 KB |
Output is correct |
3 |
Correct |
10 ms |
1020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
1656 KB |
Output is correct |
2 |
Correct |
42 ms |
2936 KB |
Output is correct |
3 |
Correct |
43 ms |
3304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
3296 KB |
Output is correct |
2 |
Correct |
68 ms |
5140 KB |
Output is correct |
3 |
Correct |
77 ms |
5752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
4216 KB |
Output is correct |
2 |
Correct |
84 ms |
6328 KB |
Output is correct |
3 |
Correct |
83 ms |
6264 KB |
Output is correct |