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 <iostream>
using namespace std;
long long findGap(int T, int N) {
long long mn, mx;
MinMax(0, 1e18, &mn, &mx);
long long gap = (mx - mn) / (N - 1);
// cout << gap << endl;
for (long long cur = mn; cur < mx;) {
long long l, r;
// cout << cur << " " << cur + gap << " ";
MinMax(cur, cur + gap, &l, &r);
// cout << l << " " << r << endl;
if (l == r) {
long long tmp = gap;
l = -1;
while (l == -1 && cur + tmp <= mx) {
tmp += gap;
// cout << "WHILE: " << cur + tmp - gap + 1 << " " << cur + tmp
// << " ";
MinMax(cur + tmp - gap + 1, cur + tmp, &l, &r);
// cout << l << " " << r << endl;
}
// cout << l << " " << cur << endl;
gap = l - cur;
// cout << gap << endl;
}
cur = r;
}
// cout << "GAP: " << gap << endl;
return gap;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |