Submission #982267

#TimeUsernameProblemLanguageResultExecution timeMemory
982267CBCodeGap (APIO16_gap)C++17
30 / 100
54 ms3792 KiB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll findGap(int T, int N) {
	if(T==1) {
		vector<ll> a(N);
		int l = 0, r = N-1;
		ll mnn = 0, mxx = 1e18;
		while(l <= r) {
			MinMax(mnn, mxx, &a[l], &a[r]);
			mnn = a[l]+1; mxx = a[r]-1;
			l++; r--;
		}
		ll ans = 0;
		for(int i = 1; i < N; i++) {
			ans = max(ans, a[i]-a[i-1]);
		}
		return ans;
	}
	else {
		ll mnn, mxx, premx;
		MinMax(0, 1e18, &mnn, &mxx);
		premx = mnn;
		ll minGap,ans; minGap = ans = (ll)ceil((long double)(mxx-mnn)/(N-1));
		for(int i = 0; i < N-1; i++) {
			MinMax(premx+1, premx+minGap, &mnn, &mxx);
			ans = max(ans,mnn-premx);
			premx = mxx;
		}
		return ans;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...