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 <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
long long ans = 0;
vector<long long> vt = {};
long long Max, Min;
MinMax(0, 1e18, &Min, &Max);
if(T == 1)
{
vt.push_back(Max);
vt.push_back(Min);
long long l = Min + 1;
long long r = Max - 1;
while(l <= r)
{
long long a, b;
MinMax(l, r, &a, &b);
if(a == -1)
{
break;
}
vt.push_back(a);
vt.push_back(b);
l = a + 1;
r = b - 1;
}
}
else
{
long long qr = (Max - Min + N - 2) / (N - 1);
ans = qr;
for(long long x = Min; x <= Max ; x += qr + 1)
{
long long xa,xb;
MinMax(x,x+qr,&xa,&xb);
vt.push_back(xa),vt.push_back(xb);
}
}
sort(vt.begin(), vt.end());
for(int i = 1; i < vt.size(); i++) ans = max(ans, vt[i] - vt[i - 1]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:44:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < vt.size(); i++) ans = max(ans, vt[i] - vt[i - 1]);
~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |