Submission #967791

#TimeUsernameProblemLanguageResultExecution timeMemory
967791TAhmed33Gap (APIO16_gap)C++98
0 / 100
31 ms3100 KiB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
const ll inf = 1e18;
pair <ll, ll> ask (ll l, ll r) {
	if (l > r) return {-1, -1};
	ll mn = l, mx = r;
	MinMax(l, r, &mn, &mx);
	return {mn, mx};
}
ll findGap (int t, int n) {
	auto g = ask(0, inf);
	ll ans = 0;
	while (g.first != g.second) {
		auto h = ask(g.first + 1, g.second - 1);
		if (h.first == -1) {
			ans = max(ans, g.second - g.first);
			break;
		}
		ans = max(ans, g.second - h.second);
		ans = max(ans, h.first - g.first);
		g = h;
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...