제출 #1175231

#제출 시각아이디문제언어결과실행 시간메모리
1175231raspyGap (APIO16_gap)C++20
57.18 / 100
44 ms1148 KiB
#include "gap.h"
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int inf = 1e18;

long long findGap(int32_t t, int32_t n)
{
	int mn, mx;
	MinMax(0, inf, &mn, &mx);
	int ds = mx-mn;
	int kor = (ds+n-2)/(n-1);
	if (n==2)
		return mx-mn;
	int pr = mn, rez = 0, zd = 0;
	for (int i = mn; i+kor < mx; i+=kor+1)
	{
		zd = i;
		int tr = 0, tmx = 0;
		MinMax(i, i+kor, &tr, &tmx);
		if (tr == -1) continue;
		rez = max(rez, tr-pr);
		pr = tmx;
	}
	int tmx = 0;
	MinMax(zd, mx, &mn, &tmx);
	if (mn != -1)
		rez = max(rez, mn-pr);
	return rez;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...