제출 #388538

#제출 시각아이디문제언어결과실행 시간메모리
388538talant117408Gap (APIO16_gap)C++17
30 / 100
56 ms2240 KiB
#include "gap.h"
#include <bits/stdc++.h>
 
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll findGap(int T, int n) {
	vector <ll> v;
	ll l = 1, r = 1e18;
	ll mn = 0, mx = 0;
	while (l <= r) {
		if (sz(v) == n) break;
		MinMax(l, r, &mn, &mx);
		if (mn == -1 && mx == -1) {
			break;
		}
		v.pb(mn);
		if (mn != mx) v.pb(mx);
		l = mn+1; r = mx-1;
	}
	sort(all(v));
	ll ans = 0;
	for (int i = 0; i < n-1; i++) ans = max(ans, v[i+1]-v[i]);
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...