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>
#include "gap.h"
using namespace std;
typedef long long ll;
const ll inf = 1e18;
vector <ll> a;
pair <ll, ll> ask (ll l, ll r) {
if (l > r) return {-1, -1};
ll mn = l, mx = r;
MinMax(l, r, &mn, &mx);
return {mn, mx};
}
ll findGap (int t, int n) {
auto g = ask(0, inf);
ll ans = 0;
ll cur = g.first;
while (cur != g.second) {
ll l = cur + 1, r = g.second, ne = -1;
while (l <= r) {
ll mid = (l + r) / 2;
auto h = ask(cur, mid);
if (h.second == cur) {
l = mid + 1;
} else {
r = mid - 1; ne = mid;
}
}
ans = max(ans, ne - cur);
cur = ne;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |