Submission #1168266

#TimeUsernameProblemLanguageResultExecution timeMemory
1168266stdfloatGap (APIO16_gap)C++20
78.54 / 100
40 ms1224 KiB
#include <bits/stdc++.h>
#include "gap.h"
// #include "grader.cpp"
using namespace std;

using ll = long long;

ll findGap(int T, int n) {
	if (T == 2) {
		ll s, t;
		MinMax(LLONG_MIN, LLONG_MAX, &s, &t);

		ll x = s, mx = 0, l = (t - s) / (n + 1);
		while (s <= t) {
			ll a, b;
			MinMax(s, s + l, &a, &b);

			if (~a) {
				mx = max(mx, a - x);
				x = b;
			}

			s += l + 1;
		}

		return mx;
	}

	ll s = LLONG_MIN, t = LLONG_MAX, mx = 0;
	for (int i = 0; i < ((n + 1) >> 1); i++) {
		ll x, y;
		MinMax(s + 1, t - 1, &x, &y);
	
		if (i) mx = max({mx, x - s, t - y});
		s = x; t = y;
	}

	return max(mx, t - s);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...