#include <iostream>
using namespace std;
const int MAXN = 1e6 + 10;
int n, nus=0;
long long a[MAXN];
int main()
{
cin >> n;
for(int i=0;i<n;i++) cin>>a[i];
int mi=0, ma=n-1;
while(ma > mi){
if(a[ma] == a[mi]){
mi++;
ma--;
continue;
}
if(a[ma] > a[mi]){
a[mi+1] += a[mi];
mi++;
} else {
a[ma-1] += a[ma];
ma--;
}
nus++;
}
cout << nus << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 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 |
1 ms |
404 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
1084 KB |
Output is correct |
2 |
Correct |
17 ms |
1312 KB |
Output is correct |
3 |
Correct |
18 ms |
1276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
3804 KB |
Output is correct |
2 |
Correct |
69 ms |
4572 KB |
Output is correct |
3 |
Correct |
80 ms |
5284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
7800 KB |
Output is correct |
2 |
Correct |
127 ms |
8236 KB |
Output is correct |
3 |
Correct |
141 ms |
9180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
153 ms |
10116 KB |
Output is correct |
2 |
Correct |
158 ms |
10184 KB |
Output is correct |
3 |
Correct |
156 ms |
10236 KB |
Output is correct |