Submission #261800

#TimeUsernameProblemLanguageResultExecution timeMemory
261800amoo_safarGap (APIO16_gap)C++14
0 / 100
88 ms3308 KiB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

typedef long long ll;

const ll Inf = 1e18;

ll findGap(int Tc, int N){
	assert(Tc == 2);
	ll L, R, S, T;
	MinMax(0ll, Inf, &L, &R);
	ll D = (R - L) / (N - 1);
	ll md = (R - L) % (N - 1);
	ll pos = L;
	ll st;
	vector<ll> V;
	for(int i = 0; i < N - 1; i++){
		st = D;
		if(i < md) st ++;
		MinMax(pos, pos + st - 1, &S, &T);
		if(S != -1){
			V.push_back(S);
			V.push_back(T);
		}
		pos += st;
	}
	sort(V.begin(), V.end());
	ll ans = D + min(md, 1ll);
	for(int i = 0; i + 1 < (int) V.size(); i++) ans = max(ans, V[i + 1] - V[i]);
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...