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>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
//#include "game.h"
#include "gap.h"
ll answer = 1e18;
void solve(ll l, ll r){
//cout << l << " " << r << endl;
answer = min(answer,r-l);
ll mid = (l+r)/2;
ll a,b;
if(l+1 <= mid)MinMax(l+1,mid,&a,&b);
if(a != -1){
if(a == b){
answer = min(a-l,answer);
} else {
answer = min(a-l,answer);
solve(a,b);
}
}
ll k = b;
if(mid+1 <= r-1)MinMax(mid+1,r-1,&a,&b);
if(a != -1){
answer = min(answer,a-k);
if(a == b){
answer = min(r-a,answer);
} else {
answer = min(r-a,answer);
solve(a,b);
}
}
}
long long findGap(int T, int N)
{
ll pirveli, bolo;
MinMax(1,1e18,&pirveli,&bolo);
//cout << pirveli << " " << bolo << endl;
solve(pirveli,bolo);
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |