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 <algorithm>
#include <iostream> 
using namespace std;
const long long MIN = 0;
const long long MAX = 1'000'000'000'000'000'000;
long long findGap(int T, int N)
{
	if (T == 1) {
		long long mn, mx; 
		long long prev_mn, prev_mx;
		long long sol = 0;
		MinMax(MIN, MAX, &prev_mn, &prev_mx);
		for (int i = 3; i <= N; i+=2) {
			MinMax(prev_mn+1, prev_mx-1, &mn, &mx);
			sol = max(sol, prev_mx-mx);
			sol = max(sol, mn-prev_mn);
			prev_mn = mn;
			prev_mx = mx;
		}
		if (prev_mn != prev_mx) {
			sol = max(sol, prev_mx-prev_mn);
		}
		return sol;
	} else if (T == 2) {
		long long mn, mx;
		MinMax(MIN, MAX, &mn, &mx);
		long long diff = (mx-mn+1 + N-2)/(N-1), sol = 0, prev_mx = MAX, st = mn;
		while (st <= mx) {
			long long en = min(MAX, st+diff), cur_mn, cur_mx;
			MinMax(st,  en, &cur_mn, &cur_mx);
			if (cur_mn != -1) {
				sol = max(sol, cur_mn - prev_mx);
				prev_mx = cur_mx;
			}
			st += diff+1;
		}
		return sol;
	}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |