# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384660 | zoooma13 | Hacker (BOI15_hac) | C++14 | 467 ms | 22472 KiB |
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 main()
{
int n ,sum = 0;
scanf("%d",&n);
vector <int> a(n);
for(int&i : a)
scanf("%d",&i) ,sum += i;
a.insert(a.end() ,a.begin() ,a.end());
vector <int> b(n);
for(int i=0; i<n/2; i++)
b[0] += a[i];
for(int i=1; i<n; i++)
b[i] = b[i-1] - a[i-1] + a[i+n/2-1];
b.insert(b.end() ,b.begin() ,b.end());
multiset <int> ms;
for(int i=0; i<(n+1)/2; i++)
ms.insert(b[i]);
int ans = sum - *ms.rbegin();
for(int i=0; i<n; i++){
ms.erase(ms.find(b[i]));
ms.insert(b[i+(n+1)/2]);
ans = max(ans ,sum - *ms.rbegin());
}
printf("%d\n",ans);
}
Compilation message (stderr)
# | 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... |