# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
807854 | nonono | Hacker (BOI15_hac) | C++14 | 62 ms | 10696 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;
const int mxN = 1e6 + 5;
int n, m;
int a[mxN];
int b[mxN];
int main() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i ++) {
cin >> a[i];
a[n + i] = a[i];
}
m = (n + 1) / 2;
for(int i = 1; i <= 2 * n; i ++) {
b[i] += b[i - 1] + a[i];
if(i >= m) b[i] -= a[i - m];
}
deque<int> dq;
int result = 0;
for(int i = m; i <= 2 * n; i ++) {
while(!dq.empty() && i - dq.front() >= m) dq.pop_front();
while(!dq.empty() && b[dq.back()] >= b[i]) dq.pop_back();
dq.push_back(i);
if(i >= 2 * m - 1) result = max(result, b[dq.front()]);
}
cout << result << "\n";
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... |