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