Submission #161632

#TimeUsernameProblemLanguageResultExecution timeMemory
161632kostia244Gap (APIO16_gap)C++14
48.54 / 100
154 ms3428 KiB
#include "gap.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
long long findGap(int T, int N) {
	ll l = 0, r = 1e18, mn, mx, tl, tr;
	MinMax(l, r, &mn, &mx);
	ll step = (mx - mn + N - 1) / N;
	l = 0, r = step;
	ll ans = 0;
	vector<ll> x;
	while (true) {
		MinMax(l, r, &tl, &tr);
		if (tl != -1) {
			x.pb(tl);
			x.pb(tr);
		}
		if (r == mx)
			break;
		l += step;
		r += step;
		r = min(r, mx);
	}
	for (int i = 1; i < x.size(); i++)
		ans = max(ans, x[i] - x[i - 1]);
	return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < x.size(); i++)
                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...