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 <bits/stdc++.h>
#ifdef atom
#include "grader.cpp"
#else
#include "gap.h"
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
long long findGap(int T, int n)
{
ll left, right;
MinMax(0, 1e18, &left, &right);
ll best = 0;
if(T == 1)
{
ll lmin = left, lmax = right;
for(int i = 2; i< n; i+= 2)
{
ll mmin, mmax;
MinMax(lmin+1, lmax-1, &mmin, &mmax);
best = max(best, mmin-lmin);
best = max(best, lmax-mmax);
lmin = mmin;
lmax = mmax;
}
best = max(best, lmax-lmin);
}
else
{
ll last = left;
ll sz = (right-left+n-1)/n;
for(ll s = left+1, e = left+sz, i = 0; i< n; s+= sz, e+=sz)
{
if(e>= right) e = right-1;
if(s> e) break;
ll mmin, mmax;
MinMax(s, e, &mmin, &mmax);
if(mmin != -1)
{
best = max(best, mmin-last);
last = mmax;
}
}
best = max(best, right-last);
}
return best;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |