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>
using namespace std;
 
#include "gap.h"
 
const long long MAX_A = 1e18;
 
long long findGap(int T, int N) {
	if (T == 1) {
		long long l = 1, r = MAX_A;
		vector<long long> A;
		for (int i = 0; i < (N + 1) / 2; i++) {
			long long nl, nr;
			MinMax(l, r, &nl, &nr);
			A.push_back(nl);
			A.push_back(nr);
			l = nl + 1, r = nr - 1;
		}
		sort(A.begin(), A.begin() + N);
		long long ans = 0;
		for (int i = 1; i < N; i++)	
			ans = max(ans, A[i] - A[i - 1]);
		return ans;
	} else {
		long long l, r;
		MinMax(1, MAX_A, &l, &r);
		long long step = (r - l - 1) / (N - 1);
		long long lb, ans = step;
		for (lb = l; lb + step < r; lb += step + 1) {
			long long nl, nr;
			MinMax(lb, lb + step, &nl, &nr);
			if (nl != -1 && nr != -1) {
				ans = max(ans, nl - l);
				l = nr;
			}
		} 
		long long nl, nr;
		MinMax(lb, r, &nl, &nr);
		if (nl != -1 && nr != -1) 
			ans = max(ans, nl - l);
		return ans;
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |