#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> nums;
int main() {
cin >> n;
nums.resize(n);
for (int i = 0; i < n; i++)
cin >> nums[i];
int ans = 0;
int l = 0, r = n-1;
int suml = nums[0], sumr = nums[n-1];
while (l < r) {
if (suml == sumr) {
suml = nums[l+1];
sumr = nums[r-1];
l++;
r--;
} else if (suml < sumr) {
suml += nums[l+1];
ans++;
l++;
} else {
sumr += nums[r-1];
ans++;
r--;
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
848 KB |
Output is correct |
2 |
Correct |
11 ms |
940 KB |
Output is correct |
3 |
Correct |
11 ms |
1016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
2396 KB |
Output is correct |
2 |
Correct |
39 ms |
2992 KB |
Output is correct |
3 |
Correct |
46 ms |
3412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
4944 KB |
Output is correct |
2 |
Correct |
70 ms |
5192 KB |
Output is correct |
3 |
Correct |
79 ms |
5716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
6216 KB |
Output is correct |
2 |
Correct |
107 ms |
6224 KB |
Output is correct |
3 |
Correct |
109 ms |
6372 KB |
Output is correct |