# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
630116 | Neos | Hacker (BOI15_hac) | C++14 | 139 ms | 10164 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;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using ii = pair<ll, ll>;
#define fastIO ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define MASK(x) (1ll << (x))
template<class X, class Y>
bool minimize(X &x, const Y &y) {
X eps = 1e-9;
if (x > y + eps) {
x = y;
return true;
} else return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
return true;
} else return false;
}
const int N = 5e5 + 7, oo = 1e9 + 7;
int n, a[N];
signed main() {
fastIO;
if (fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], a[i + n] = a[i];
for (int i = 1; i <= 2 * n; i++) a[i] += a[i - 1];
vector<int> ret(n + 1, oo);
multiset<int> val; int len = n + 1 >> 1;
for (int i = 1; i <= 2 * n; i++) {
if (i + len - 1 <= 2 * n) val.insert(a[i + len - 1] - a[i - 1]);
if (i > len) val.erase(val.find(a[i - 1] - a[i - 1 - len]));
int prv = (i - 1) % n + 1;
minimize(ret[prv], *val.begin());
}
int ans = 0;
for (int i = 1; i <= n; i++) maximize(ans, ret[i]);
cout << ans;
}
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... |