Submission #792567

#TimeUsernameProblemLanguageResultExecution timeMemory
792567IvanJGap (APIO16_gap)C++17
59.04 / 100
53 ms1084 KiB
#include "gap.h"
#include<bits/stdc++.h>

#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

ll findGap(int T, int N) {
	if(T == 1) {
		return 0;
	}
	if(T == 2) {
		ll lo = 0, hi = 1e18;
		MinMax(lo, hi, &lo, &hi);
		ll min_gap = (hi - lo) / ((ll)N - 1);
	
		ll ans = 0;
		ll x = lo + 1, lst = lo, l, r;
		while(x < hi) {
			MinMax(x, x + min_gap - 1, &l, &r);
			if(l != -1) 
				ans = max(ans, l - lst);
			x += min_gap;
			if(r != -1) lst = r;
		}
		if(x == hi) ans = max(ans, hi - lst);
		return ans;
	}
}

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...