Submission #1090312

#TimeUsernameProblemLanguageResultExecution timeMemory
1090312Alihan_8Gap (APIO16_gap)C++17
59.04 / 100
54 ms2820 KiB
#include "gap.h"

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

pair <i64,i64> qry(i64 s, i64 t){
	i64 mn, mx;
	
	MinMax(s, t, &mn, &mx);
	
	return {mn, mx};
}

long long findGap(int T, int n){
	auto [mn, mx] = qry(0, (i64)1e18);
	
	i64 lb = (mx - mn) / (n - 1), opt = lb;
	
	i64 pv = mn, j = mn + 1;
	
	while ( j <= mx ){
		auto [l, r] = qry(j, j + lb - 1);
		
		if ( l != -1 ){
			opt = max(opt, l - pv);
			pv = r;
		}
		
		j += lb;
	}
	
	return opt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...