This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5e5+5;
int n, v[maxn], pre[maxn];
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> v[i];
}
pre[0] = v[0];
for (int i = 1; i < n; i++) {
pre[i] = pre[i-1] + v[i];
}
int sz = (n+1)/2;
vector<int> sums;
for (int i = 0; i < n; i++) {
int l = (i-sz+n) % n;
if (l < i) {
sums.push_back(pre[i]-pre[l]);
}
else {
sums.push_back(pre[n-1] - (pre[l]-pre[i]));
}
}
sort(sums.begin(),sums.end());
/*
for (int j: sums) {
cout << j << ' ';
}
cout << '\n';
*/
cout << sums[n/2] << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |