| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 945364 | wii | Gap (APIO16_gap) | C++17 | 42 ms | 4000 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll findGap(int T, int N) {
ll res = 0;
if (T == 1) {
vector<ll> a;
for (ll l = 0, r = 1e18; l <= r && a.size() < N; ) {
ll mn, mx;
MinMax(l, r, &mn, &mx);
a.push_back(mn);
a.push_back(mx);
l = mn + 1;
r = mx - 1;
}
sort(a.begin(), a.end());
for (int i = 1; i < a.size(); ++i)
res = max(res, a[i] - a[i - 1]);
} else {
ll l, r;
MinMax(0, 1e18, &l, &r);
ll step = (r - l + 1) / N;
res = step;
for (ll i = l + 1, pre = l; i <= r; i += step + 1) {
ll mn, mx;
MinMax(i, i + step, &mn, &mx);
if (mn != -1) {
res = max(res, mn - pre);
pre = mx;
}
}
}
return res;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
