#include<bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
const int N=5555555;
ll n,a[N],pre[N],suf[N],ans;
set <ll> st;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for (ll i=0;i<n;i++){
cin>>a[i];
}
ll i=0,j=n-1;
while (i<j)
{
if (a[i]<a[j])
{
a[i+1]+=a[i];
i++;
ans++;
}
else if (a[i]>a[j])
{
a[j-1]+=a[j];
j--;
ans++;
}
else
{
i++;
j--;
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
844 KB |
Output is correct |
2 |
Correct |
5 ms |
1100 KB |
Output is correct |
3 |
Correct |
6 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
2968 KB |
Output is correct |
2 |
Correct |
21 ms |
3560 KB |
Output is correct |
3 |
Correct |
26 ms |
4200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
6192 KB |
Output is correct |
2 |
Correct |
46 ms |
8128 KB |
Output is correct |
3 |
Correct |
54 ms |
9168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
7904 KB |
Output is correct |
2 |
Correct |
54 ms |
10188 KB |
Output is correct |
3 |
Correct |
54 ms |
10172 KB |
Output is correct |