# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
409620 | iulia13 | Hacker (BOI15_hac) | C++14 | 484 ms | 24380 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 <set>
using namespace std;
const int N = 5e5 + 5;
int v[3 * N];
int sum[2 * N];
struct ura{
int x, id;
};
set <pair<int, int>> s;
int main()
{
int n, j, cnt = n, i;
cin >> n; cnt = n;
for (i = 1; i <= n; i++)
cin >> v[i];
for (j = 1; j < 3; j++)
for (i = 1; i <= n; i++)
v[++cnt] = v[i];
int st = 1, dr = (n + 1) / 2;
for (i = st; i <= dr; i++)
sum[1] += v[i];
while (st <= 2 * n)
{
sum[st + 1] = sum[st];
sum[st + 1] -= v[st];
st++;
dr++;
sum[st] += v[dr];
}
st = n - (n + 1) / 2 + 2;
dr = n + 1;
for (i = st; i <= dr; i++)
s.insert({sum[i], i});
pair<int, int> ans = *(s.begin());
while (dr <= 2 * n)
{
s.erase({sum[st], st});
st++;
if (st == 15)
st = 15;
dr++;
s.insert({sum[dr], dr});
if (ans.first < (*(s.begin())).first)
ans = *(s.begin());
}
cout << ans.first;
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... |