Submission #261450

#TimeUsernameProblemLanguageResultExecution timeMemory
261450srvltGap (APIO16_gap)C++14
0 / 100
44 ms4984 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include "gap.h"

const int n0 = 1e5 + 123;
ll l[n0], r[n0];

ll findGap(int T, int N) {
	ll MAX = 1e18, mn = 0, mx = 0;
	MinMax(0ll, MAX, & mn, & mx);
	ll step = (mx - mn) / (N - 1);
	ll ans = step, L = 0, R = mn - 1;
	int last = -1;
	for (int i = 1; i < N; i++) {
		L = R + 1;
		R = L + step;
		MinMax(L, R, & l[i], & r[i]);
		if (i > 1 && l[i] != -1 && last != -1)
			ans = max(ans, l[i] - r[last]);
		if (l[i] != -1)
			last = r[i];
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...