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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll findGap(int T, int n){
if(T == 1){
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
for(int i = 0; i < (n+1)/2-1; i++){
ll x, y;
MinMax(a+1, b-1, &x, &y);
ans = max(ans, max(x-a, b-y));
a = x, b = y;
}
if(n%2 == 0) ans = max(ans, b-a);
return ans;
}
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
ll k = (b-a+n-2)/(n-1);
ll prev = a;
int cnt = 0;
for(ll i = a; i <= b; i+=k){
cnt++;
ll x, y;
if(i == b) x = b, y = b;
else MinMax(i, min(i+k-1, b), &x, &y);
if(x == -1) continue;
ans = max(ans, x-prev);
prev = y;
}
assert(cnt <= n);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |