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 <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long n;
vector<long long> v;
long long findGap(int t,int N)
{
n=N;
long long l=0,r=1e18;
while(l<=r&&v.size()<n)
{
long long mn,mx;
MinMax(l,r,&mn,&mx);
if(mn==-1)break;
//cout<<l<<" "<<r<<endl;
v.push_back(mn);
if(mn!=mx)v.push_back(mx);
l=mn+1,r=mx-1;
}
long long ans=0;
sort(v.begin(),v.end());
for(int i=1; i<v.size(); i++)
ans=max(ans,v[i]-v[i-1]);
return ans;
}
/*int main()
{
long long d=0;
int x;
cin>>x>>nn;
for(int i=1;i<=nn;i++)
{
cin>>a[i];
if(i!=1)d=max(d,a[i]-a[i-1]);
}
long long answer=findGap(1,nn);
cout<<d<<" "<<answer<<endl;
}*/
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:11:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
11 | while(l<=r&&v.size()<n)
| ~~~~~~~~^~
gap.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=1; i<v.size(); i++)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |