#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN=1e6+2;
ll N,A[MN],ans=0;
int main() {
ios::sync_with_stdio(0);cin.tie(0);
cin>>N;
for(int i=1;i<=N;i++) cin>>A[i];
int l=1,r=N;
while(r>l) {
if(A[l]>A[r]) {
ans++;
A[r-1]+=A[r];
r--;
} else if(A[l]<A[r]) {
ans++;
A[l+1]+=A[l];
l++;
} else {
l++;r--;
}
}
cout<<ans<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
996 KB |
Output is correct |
2 |
Correct |
6 ms |
1236 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
3660 KB |
Output is correct |
2 |
Correct |
32 ms |
4508 KB |
Output is correct |
3 |
Correct |
27 ms |
5224 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
7688 KB |
Output is correct |
2 |
Correct |
43 ms |
8140 KB |
Output is correct |
3 |
Correct |
47 ms |
9124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
9904 KB |
Output is correct |
2 |
Correct |
57 ms |
10180 KB |
Output is correct |
3 |
Correct |
52 ms |
10184 KB |
Output is correct |