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;
int n,a[500005],sp[500005],k;
vector<int> adg[500005],del[500005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
k = n / 2 + n % 2;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
sp[i] = sp[i - 1] + a[i];
for (int i = 1; i <= n; i++)
{
if (i + k - 1 <= n)
{
int vl = sp[i + k - 1] - sp[i - 1];
adg[i].push_back(vl);
del[i + k].push_back(vl);
}
else
{
int vl = sp[n] - sp[i - 1] + sp[i + k - 1 - n];
adg[i].push_back(vl);
adg[1].push_back(vl);
del[i + k - n].push_back(vl);
}
}
multiset<int> ms;
int mxm = 0;
for (int i = 1; i <= n; i++)
{
for (auto it : adg[i])
ms.insert(it);
for (auto it : del[i])
ms.erase(ms.find(it));
mxm = max(mxm,*ms.begin());
}
cout << mxm;
return 0;
}
# | 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... |