This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
long long findGap(int T, int N)
{
if (!N) return 0;
vector<ll> a;
ll res = 0;
if (--T) {
ll mn, mx,bnd;
MinMax(0,1e18,&mn,&bnd);
ll d = (bnd - mn)/(N-1);
a.push_back(mn); a.push_back(bnd);
ll l = mn, r = mn + d;
res = d;
for (;l< bnd;l+=d+1,r+=d+1) {
MinMax(l, r, &mn, &mx);
if (mn != -1) a.push_back(mn);
if (mx != -1) a.push_back(mx);
}
}
else {
ll mn = -1, mx = 1e18+1;
for (int i = N; i > 0; i -= 2) {
MinMax(mn + 1, mx - 1,&mn,&mx);
a.push_back(mn); a.push_back(mx);
}
}
sort(a.begin(), a.end());
for (int i = 1; i < a.size(); ++i) {
ll d = a[i] - a[i - 1];
if (res < d) res = d;
}
return res;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < a.size(); ++i) {
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |