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 mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
long long findGap(int T, int n)
{
vector<LL> v;
LL x=-1,y=1e18+1,nx,ny,ret=0,cnt=0;
if(T==1) {
while(cnt<(n+1)/2) {
MinMax(x+1,y-1,&nx,&ny);
x=nx; y=ny;
v.pb(x);
cnt++;
if(x==y)
break;
v.pb(y);
}
sort(v.begin(),v.end());
/*for(int i=0;i<v.size();++i)
cout<<v[i]<<" ";
cout<<endl;*/
for(int i=1;i<v.size();++i)
ret=max(ret,v[i]-v[i-1]);
}
else {
LL mn,mx;
MinMax(0,(LL)(1e18),&mn,&mx);
LL dif=(mx-mn-1+n-2)/(n-1);
v.pb(mn);
v.pb(mx);
if(dif==0)
return 1LL;
for(LL l=mn+1;l<mx;l+=dif) {
MinMax(l,min(l+dif-1,mx-1),&nx,&ny);
if(nx!=-1) {
v.pb(nx);
if(nx!=ny)
v.pb(ny);
}
}
sort(v.begin(),v.end());
for(int i=1;i<v.size();++i)
ret=max(ret,v[i]-v[i-1]);
}
return ret;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<v.size();++i)
^
gap.cpp:54:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<v.size();++i)
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |