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);
while(a+1 < b){
ll _a, _b;
MinMax(a+1, b-1, &_a, &_b);
if(_a == -1) break;
ans = max(ans, max(_a-a, b-_b));
swap(a, _a), swap(b, _b);
}
ans = max(ans, b-a);
return ans;
}
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
ll k = (b-a+n-1)/n;
ll prev = a;
int cnt = 0;
for(ll i = a; i <= b; i+=k+1){
cnt++;
ll x, y;
MinMax(i, min(i+k, 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... |