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>
using namespace std;
typedef long long int ll;
ll n,s,l,r,x,y,z,w,a[1100000],i,j,k,m,mx,gap;
long long findGap(int T, int N)
{
n=N;
if(T==1)
{
l=0;
r=1e18-1;
x=1;
y=n;
while(l<r)
{
MinMax(l,r,&l,&r);
a[x]=l;
a[y]=r;
x++;
y--;
if(l==r||x>y)
break;
l++;
r--;
}
for(i=1;i<n;i++)
{
s=max(s,a[i+1]-a[i]);
}
return s;
}
l=0;
r=1e18-1;
MinMax(l,r,&x,&y);
gap=(y-x)/(n-1);
l=x+1;
mx=l;
while(1)
{
r=min(l+gap-1,y-1);
//printf("(%lld,%lld)\n",l,r);
MinMax(l,r,&z,&w);
if(z==-1)
{
l+=gap;
if(l>=y)
break;
continue;
}
s=max(s,z-mx);
mx=w;
l+=gap;
if(l>=y)
break;
}
s=max(s,r-mx);
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |