#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<ll> v(2*n);
for (int i=0; i<n; i++) {
cin >> v[i];
v[i+n] = v[i];
}
vector<ll> p(2*n+1,0);
for (int i=1; i<=2*n; i++) {
p[i] = v[i - 1] + p[i - 1];
}
int ceil = n/2;
if (n % 2 == 1) ceil++;
int ct = 0;
vector<ll> ans;
for (int i=ceil; ; i++) {
if (ct == n) break;
ll d = p[i] - p[ct];
ans.push_back(d);
ct++;
}
sort(ans.begin(),ans.end());
cout << ans[n/2];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |