Submission #41247

#TimeUsernameProblemLanguageResultExecution timeMemory
41247Just_Solve_The_ProblemGap (APIO16_gap)C++11
0 / 100
93 ms39388 KiB
#include <gap.h>
#include <bits/stdc++.h> 

#define ll long long

using namespace std;

ll findGap(int t, int n) {
	ll l, r;
	MinMax(0, 1e18, &l, &r);
	l++; r--;
	ll dif = (r - l + 1) / n;
	ll start = l;
	ll fin = start + dif - 1;
	ll fre = 0;
	ll mx = 0; 
	ll ans = 0;
	while (1) {
		ll l1, r1;
		MinMax(start, fin, &l1, &r1);
		if (l1 == -1) {
			fre += dif;
		} else {
			if (fre != 0) {
				ans = max(ans, fre + mx + (l1 - start + 1));
			}
			fre = 0;             
			mx = fin - r1;
		}
		if (fin == r) break;      
		start = fin + 1;
		fin = min(start + dif - 1, r);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...