Submission #542391

#TimeUsernameProblemLanguageResultExecution timeMemory
542391farhan132Gap (APIO16_gap)C++17
53.51 / 100
63 ms1188 KiB
#include "gap.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<ll> vll;
typedef pair<ll , ll> ii;
typedef vector< ii > vii;
typedef pair < pair < ll , ll > , pair < ll , ll > > cm; 
typedef tuple < int, ll, ll > tp;
 
#define ff first
#define ss second
#define pb push_back
#define in insert

ii get(ll x, ll y){
	ll mn , mx;
	MinMax(x, y, &mn, &mx);
	return {mn, mx};
}

long long findGap(int T, int n)
{
	auto [l, r] = get(0, 1e18);
	if(r - l + 1 == n) return 1;
	ll block = (((r - l + 1) - n) + n - 1) / (n - 1);
	vector < ii > v;
	ll cur = l;
	ll last = l;
	ll ans = 0;
	while(cur <= r){
		ll L = cur , R = min(cur + block - 1, r);
		auto [x, y] = get(L , R);
		cur = R + 1;
		if(x == -1){
			continue;
		}
		if(last != -1) ans = max(ans , x - last);
		last = y;
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...