#include <bits/stdc++.h>
using namespace std;
long long n, a[1000000], s, e, o;
int main(){
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
e = n-1;
while(s != e && s < e){
if(a[s] == a[e]){
s++;
e--;
} else if(a[s] < a[e]){
a[s+1] += a[s];
s++;
o++;
} else {
a[e-1] += a[e];
e--;
o++;
}
}
cout << o;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 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 |
252 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 |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1144 KB |
Output is correct |
2 |
Correct |
28 ms |
1272 KB |
Output is correct |
3 |
Correct |
29 ms |
1332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
3676 KB |
Output is correct |
2 |
Correct |
115 ms |
4548 KB |
Output is correct |
3 |
Correct |
138 ms |
5324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
7892 KB |
Output is correct |
2 |
Correct |
212 ms |
8312 KB |
Output is correct |
3 |
Correct |
237 ms |
9208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
264 ms |
9976 KB |
Output is correct |
2 |
Correct |
272 ms |
10232 KB |
Output is correct |
3 |
Correct |
264 ms |
10272 KB |
Output is correct |