#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector <int> v(n);
for(int i = 0; i < n; i++) cin >> v[i];
int sol = 0, lo = 0, hi = n-1;
while(lo < hi){
if(v[lo] == v[hi]){
lo++, hi--;
continue;
}
else if(v[lo] < v[hi]){
v[lo + 1] += v[lo];
lo++;
}
else{
v[hi - 1] += v[hi];
hi--;
}
sol++;
}
cout << sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
652 KB |
Output is correct |
3 |
Correct |
2 ms |
748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1008 KB |
Output is correct |
2 |
Correct |
2 ms |
1016 KB |
Output is correct |
3 |
Correct |
2 ms |
1028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1028 KB |
Output is correct |
2 |
Correct |
3 ms |
1088 KB |
Output is correct |
3 |
Correct |
2 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1088 KB |
Output is correct |
2 |
Correct |
2 ms |
1088 KB |
Output is correct |
3 |
Correct |
2 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1088 KB |
Output is correct |
2 |
Correct |
2 ms |
1088 KB |
Output is correct |
3 |
Correct |
2 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1396 KB |
Output is correct |
2 |
Correct |
11 ms |
1684 KB |
Output is correct |
3 |
Correct |
10 ms |
1904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
3664 KB |
Output is correct |
2 |
Correct |
37 ms |
4904 KB |
Output is correct |
3 |
Correct |
42 ms |
6176 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
8768 KB |
Output is correct |
2 |
Correct |
66 ms |
10488 KB |
Output is correct |
3 |
Correct |
83 ms |
12816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
15108 KB |
Output is correct |
2 |
Correct |
81 ms |
17384 KB |
Output is correct |
3 |
Correct |
82 ms |
19432 KB |
Output is correct |