#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n ;
cin>>n;
vector<int> v(n);
vector<int> pref(n);
for(int i = 0 ;i < n ; i++)
{
cin>>v[i];
pref[i] = v[i];
if(i)
pref[i]+=pref[i - 1];
}
int ans = LLONG_MAX;
for(int i = 1 + n/2 ; i <= n ; i++)
{
int j = (i % n);
int k = (j + (n+1)/2 - 1 + n)%n;
if(k >= j)
ans = min(ans , pref[k] - (j ? pref[j - 1] : 0));
else
ans = min(ans , pref[n - 1] - (j ? pref[j - 1] : 0) + pref[k]);
}
cout<<ans<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
11 ms |
1944 KB |
Output is correct |
5 |
Correct |
24 ms |
4188 KB |
Output is correct |
6 |
Correct |
33 ms |
5204 KB |
Output is correct |
7 |
Correct |
48 ms |
6272 KB |
Output is correct |
8 |
Correct |
66 ms |
10324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |