# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
926369 | Ludissey | Hacker (BOI15_hac) | C++14 | 45 ms | 5364 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>
int main() {
int n; scanf("%d",&n);
int half=((n+1)/2);
std::vector<int> v(n*2,0);
for (int i = 0; i < (int)v.size(); i++) {
if(i<n) {
scanf("%d",&v[i]);
v[i+n]=v[i];
}
v[i]+=v[i-1];
}
std::deque<int> queue;
for (int i = 0; i < half; i++)
{
while(!queue.empty()&&v[queue.back()+half-1]-v[queue.back()-1]>(v[i+half-1]-v[i-1])) queue.pop_back();
queue.push_back(i);
}
int outp=v[queue.front()+half-1]-v[queue.front()-1];
for (int i = half; i < (n*2)-half; i++)
{
if(!queue.empty()&&queue.front()==i-half) queue.pop_front();
while(!queue.empty()&&v[queue.back()+half-1]-v[queue.back()-1]>(v[i+half-1]-v[i-1])) queue.pop_back();
queue.push_back(i);
outp=std::max(v[queue.front()+half-1]-v[queue.front()-1], outp);
}
std::printf("%d\n", outp);
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... |