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;
/*
void MinMax(long long x,long long y,long long* a,long long* b)
{
cout << x << ' ' << y << endl;
int aa,bb;
cin >> aa >> bb;
*a = aa,*b = bb;
}
*/
vector<long long> a;
long long findGap(int t,int n)
{
long long mn,mx,ans = 0;
MinMax(0,1e18,&mn,&mx);
if(t==1)
{
a.push_back(mn),a.push_back(mx);
int l = 1,r = n-2;
while(l<=r)
{
MinMax(mn+1,mx-1,&mn,&mx);
a.push_back(mn),a.push_back(mx);
l++,r--;
}
}
else
{
long long each = (mx-mn+n-2)/(n-1);
ans = each;
for(long long x = mn;x <= mx;x+=each+1)
{
long long xa,xb;
MinMax(x,x+each,&xa,&xb);
a.push_back(xa),a.push_back(xb);
}
}
sort(a.begin(),a.end());
for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
return ans;
}
/*
int main()
{
int x;
cin >> x;
cout << findGap(0,x);
}*/
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |