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,b;
long long findGap(int t,int n)
{
long long mn,mx;
MinMax(0,1e18,&mn,&mx);
a.push_back(mn),b.push_back(mx);
int l = 1,r = n-2;
while(l<=r)
{
MinMax(mn+1,mx-1,&mn,&mx);
a.push_back(mn),b.push_back(mx);
l++,r--;
}
long long ans = 0;
for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
for(int i = 0;i < b.size()-1;i++) ans = max(ans,b[i]-b[i+1]);
ans = max(ans,abs(a.back()-b.back()));
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:34: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]);
~~^~~~~~~~~~~~
gap.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < b.size()-1;i++) ans = max(ans,b[i]-b[i+1]);
~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |