# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
105963 | xiaowuc1 | Hacker (BOI15_hac) | C++14 | 672 ms | 18396 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 <algorithm>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;
int l[1000000];
int maxV[1000000];
void solve() {
int n;
cin >> n;
for(int i = 0; i < n; i++) {
cin >> l[i];
}
int sz = (n+1)/2;
int curr = 0;
for(int i = 0; true; i++) {
curr += l[i%n];
if(i >= sz) {
curr -= l[i-sz];
}
if(maxV[i%n]) break;
if(i >= sz-1) {
maxV[i%n] = curr;
}
}
int ret = 0;
multiset<int> all;
for(int i = 0; true; i++) {
if(i > sz-1 && i%n == sz-1) break;
all.insert(maxV[i%n]);
if(i >= sz) {
auto x = all.find(maxV[(i-sz)]);
all.erase(x);
}
if(all.size() == sz) {
ret = max(ret, *all.begin());
}
}
cout << ret << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
/*
int t;
cin >> t;
for(int i = 1; i <= t; i++) {
cout << "Case #" << i << ": ";
solve();
}
*/
solve();
}
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... |