#include <iostream>
using namespace std;
long long n, a[1000000];
int main()
{
cin>>n;
for(int i = 0; i < n; i++)
cin>>a[i];
int l = 0, r = n - 1, res = 0;
while(l < r)
{
if(a[l] == a[r])
{
l++;
r--;
continue;
}
if(a[l] < a[r])
{
a[l + 1] += a[l];
l++;
}
else
{
a[r - 1] += a[r];
r--;
}
res++;
}
cout<<res<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
312 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 |
11 ms |
1076 KB |
Output is correct |
2 |
Correct |
16 ms |
1216 KB |
Output is correct |
3 |
Correct |
14 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
3660 KB |
Output is correct |
2 |
Correct |
56 ms |
4484 KB |
Output is correct |
3 |
Correct |
66 ms |
5200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
129 ms |
7760 KB |
Output is correct |
2 |
Correct |
112 ms |
8120 KB |
Output is correct |
3 |
Correct |
146 ms |
9152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
127 ms |
9984 KB |
Output is correct |
2 |
Correct |
143 ms |
10068 KB |
Output is correct |
3 |
Correct |
131 ms |
10096 KB |
Output is correct |