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"
#include "gap.h"
using namespace std;
using ll = long long;
long long findGap(int T, int N)
{
ll cep,sag;
MinMax(1,(ll)1e18,&cep,&sag);
// assert(cep != -1 && sag != -1);
ll now = cep,ans = 0;
while(now < sag){
ll nwa,nwb;
if(now + ans + 1 >= sag){
ans = max(ans,sag - now);
break;
}
MinMax(now + 1,now + ans + 1,&nwa,&nwb);
if(nwa != -1){
ans = max(ans,nwa - now);
now = nwb;
continue;
}
ans++;
while(1){
if(now + ans * 2 >= sag){
ans = max(ans,sag - now);
now = sag;
break;
}
MinMax(now + 1,now + ans * 2,&nwa,&nwb);
if(nwa != -1){
ans = max(nwa - now,ans);
now = nwb;
break;
}
ans *= 2;
ans++;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |