# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501453 | Stickfish | Gap (APIO16_gap) | C++17 | 46 ms | 2632 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 "gap.h"
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;
const ll INF = 1.77013e18;
ll findGap(int T, int N) {
//if (T == 1) {
vector<ll> mn;
vector<ll> mx;
while (mn.size() + mx.size() < N) {
ll nmn, nmx;
if (mn.empty()) {
MinMax(1ll, INF, &nmn, &nmx);
} else {
MinMax(mn.back() + 1, mx.back() - 1, &nmn, &nmx);
}
mn.push_back(nmn);
if (nmn != nmx)
mx.push_back(nmx);
}
reverse(mx.begin(), mx.end());
for (auto x : mx) {
mn.push_back(x);
}
ll ans = 0;
for (int i = 0; i + 1 < N; ++i) {
ans = max(ans, mn[i + 1] - mn[i]);
}
return ans;
//}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |