# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
732078 | sleepntsheep | Hacker (BOI15_hac) | C++17 | 1 ms | 212 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;
#define N 500005
int n;
using ll = long long;
ll z = 0;
ll a[N], b[N];
ll ring_query2(int l, int r)
{
if (l > 0 && r <= n) return b[r] - b[l-1];
if (r > 0 && l <= 0) return ring_query2(1, r) + ring_query2(l + n, n);
if (l > 0 && l <= n && r > n) return ring_query2(l, n) + ring_query2(1, r - n);
printf("%d %d\n", l, r); assert(0);
}
ll ring_query(int l, int r)
{
ll res = ring_query2(l, r);
return res;
}
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", a+i), b[i] = b[i-1] + a[i];
int bsz = n % 2 ? (n + 1) / 2 : n / 2;
for (int i = 1; i <= n; i++) z = max(z, min(ring_query(i - bsz + 1, i), ring_query(i, i + bsz - 1)));
printf("%lld", z);
return 0;
}
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... |