Submission #491427

#TimeUsernameProblemLanguageResultExecution timeMemory
491427JooGap (APIO16_gap)C++17
70 / 100
51 ms1076 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

long long findGap(int T, int N)
{
	long long L, R;
	MinMax(0, 1e18, &L, &R);

	long long sz = (R-L-1)/(N-1), l = L+1, pre = L, ans = 0, cnt = 0;
	while(l < R){
		long long r = min(R-1, l+sz-1), mn, mx;
		if(++cnt == N){
			r = R-1;
		}
		if(l > r) break;
		MinMax(l, r, &mn, &mx);

		if(mn != -1){
			ans = max(ans, mn-pre);
			pre = mx;
		}
		l = r+1;
	}

	assert(cnt <= N);

	ans = max(ans, R-pre);

	return ans;

	//return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...