제출 #406347

#제출 시각아이디문제언어결과실행 시간메모리
406347p_squareGap (APIO16_gap)C++14
30 / 100
52 ms1908 KiB
#include<bits/stdc++.h>
#include "gap.h"

#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mp make_pair
#define se second
#define fi first

using namespace std;

ll findGap(int t, int n)
{
	ll a[n];
	ll l = 0, r = 1e18+1;
	ll ptr1, ptr2;

	for(int i = 0; 2*i<n; i++)
	{
		MinMax(l, r, &ptr1, &ptr2);
		a[2*i] = ptr1;
		if(2*i < n-1)
			a[2*i+1] = ptr2;

		l = ptr1 + 1;
		r = ptr2 - 1;
	}

	sort(a, a+n);
	ll ma = 0;
	for(int i = 1; i<n; i++)
	{
		ma = max(ma, a[i]-a[i-1]);
	}

	return ma;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...