#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
vector<long long> tab(N);
for (int i = 0; i < N; i++)
{
cin >> tab[i];
}
int a = 0, b = N - 1;
int tot = 0;
while (a < b)
{
if (tab[a] == tab[b])
{
a++;
b--;
}
else if (tab[a] > tab[b])
{
tab[b - 1] += tab[b];
b--;
tot++;
}
else
{
tab[a + 1] += tab[a];
a++;
tot++;
}
}
cout << tot;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
304 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
9 ms |
980 KB |
Output is correct |
2 |
Correct |
12 ms |
1208 KB |
Output is correct |
3 |
Correct |
15 ms |
1300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
3668 KB |
Output is correct |
2 |
Correct |
47 ms |
4380 KB |
Output is correct |
3 |
Correct |
55 ms |
5208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
7752 KB |
Output is correct |
2 |
Correct |
88 ms |
8092 KB |
Output is correct |
3 |
Correct |
97 ms |
9124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
107 ms |
9884 KB |
Output is correct |
2 |
Correct |
108 ms |
10156 KB |
Output is correct |
3 |
Correct |
109 ms |
10184 KB |
Output is correct |