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;
#define all(v) v.begin(), v.end()
typedef long long ll;
long long findGap(int T, int N){
if(T==1){
vector<ll>v;
ll a=-1, b=1e18+1, c, d;
for(int i=0;i<N;i+=2){
if(a+1>b-1){
return 1/0;
}
MinMax(a+1, b-1, &c, &d);
v.push_back(c);
v.push_back(d);
a=c;
b=d;
}
sort(all(v));
ll ans=0;
for(int i=1;i<v.size();++i)
ans=max(ans, v[i]-v[i-1]);
return ans;
}
ll a, b;
MinMax(0, 1e18, &a, &b);
ll c=(b-a+N-2)/(N-1);
ll ans=c;
while(a!=b){
ll d=-1, e;
for(int i=1;d==-1;++i)
MinMax(a+1, a+i*c, &d, &e);
ans=max(ans, d-a);
a=e;
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:13:13: warning: division by zero [-Wdiv-by-zero]
13 | return 1/0;
| ~^~
gap.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i=1;i<v.size();++i)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |