Submission #1101305

#TimeUsernameProblemLanguageResultExecution timeMemory
1101305huyngoGap (APIO16_gap)C++17
30 / 100
42 ms5832 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long

long long findGap(int T, int N) {
	vector<ll> a;
	auto calc = [&](auto self, ll l, ll r) -> void {
		if (l > r || a.size() == N) return;
		ll x, y;
		MinMax(l, r, &x, &y);
		if (x != -1)
			a.push_back(x);
		if (y != x)
			a.push_back(y);
		self(self, x + 1, y - 1);
		};
	calc(calc, 0, 1e18);
	sort(a.begin(), a.end());
	ll res = a[1] - a[0];
	for (int i = 2; i < N; ++i)
		res = max(res, a[i] - a[i - 1]);
	return res;
}

Compilation message (stderr)

gap.cpp: In instantiation of 'findGap(int, int)::<lambda(auto:23, long long int, long long int)> [with auto:23 = findGap(int, int)::<lambda(auto:23, long long int, long long int)>]':
gap.cpp:18:20:   required from here
gap.cpp:9:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |   if (l > r || a.size() == N) return;
      |                ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...