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 <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
void f(ll l, ll r, ll &x, ll &y){
MinMax(l, r, &x, &y);
}
ll findGap(int t, int n){
ll l, r, ret = 0;
f(0, 1e18, l, r);
if(t & 1){
for(ll i = 1, x, y; 2 * i < n && r - l > 1; i++, l = x, r = y){
f(l + 1, r - 1, x, y);
if(!~x || !~y) break;
ret = max({ret, r - y, x - l});
}
}else{
for(ll d = (r - l) / (n - 1), i = l + 1; i < r; i += d){
ll x, y;
f(i, min(r - 1, i + d - 1), x, y);
if(~x && ~y) ret = max({ret, x - l, y - x}), l = y;
}
}
ret = max(ret, r - l);
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |