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<iostream>
#include "gap.h"
#define int long long
using namespace std;
long long a[200000];
/*void MinMax(long long x,long long y,int *l,int *r)
{
cout<<x<<" "<<y<<"\n";
cin>>*l>>*r;
}*/
long long findGap(int32_t t,int32_t n)
{
if(t==1)
{
int l,r;
MinMax(0,(long long)1e18,&l,&r);
a[1]=l;
a[n]=r;
int pocz=2,kon=n-1;
while(pocz<=kon)
{
MinMax(a[pocz-1]+1,a[kon+1]-1,&l,&r);
a[pocz]=l;
a[kon]=r;
pocz++;
kon--;
}
long long wynik=0;
for(int i=1;i<n;i++)
wynik=max(wynik,a[i+1]-a[i]);
return wynik;
}
else{
int l,r;
MinMax(0,(long long)1e18,&l,&r);
int koncowka=r;
int srednia=(r-l)+1;
srednia/=(n-1);
int kon=l+srednia;
for(int pocz=l;kon+srednia<=koncowka;)
{
if(r<=l)
kon+=srednia;
MinMax(pocz+1,kon,&l,&r);
if(l==-1)
kon+=srednia;
else{
srednia=max(srednia,l-pocz);
pocz=l;
}
}
return srednia;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |