# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31088 | nibnalin | Hacker (BOI15_hac) | C++14 | 693 ms | 17676 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 <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
const int maxn = int(5e5)+5, inf = int(1e9)+5;
int n, A[maxn], v[maxn];
inline int mod(int x) { return ((x%n)+n)%n; }
int main(void)
{
scanf("%d", &n);
for(int i = 0;i < n;i++) scanf("%d", &A[i]);
int sz = n/2+n%2;
for(int i = 0;i < sz;i++) v[0] += A[i];
for(int i = 1;i < n;i++)
{
v[i] = v[i-1]+A[mod(i+sz-1)]-A[i-1];
}
set<pair<int, int>> S;
for(int i = 0;i < sz;i++) S.insert({v[mod(0-i)], mod(0-i)});
int res = S.begin()->first;
for(int i = 0;i < n;i++)
{
S.erase({v[mod(i-sz)], mod(i-sz)}), S.insert({v[i], i});
res = max(res, S.begin()->first);
}
printf("%d\n", res);
}
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... |