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;
set<long long> s;
void recur(const int& N, long long lo, long long hi){
if(lo > hi) return;
if(s.size() == N) return;
long long mn, mx;
MinMax(lo, hi, &mn, &mx);
if(mn == -1ll) return;
s.insert(mn);
s.insert(mx);
long long mid = (mn + mx)/2ll;
recur(N, mn+1, mid);
recur(N, mid, mx-1);
}
long long findGap(int T, int N)
{
long long mn, mx;
if(T == 1){
long long lo = 0ll;
long long hi = 1e18;
do{
MinMax(lo, hi, &mn, &mx);
if(mn == -1) break;
s.insert(mn);
s.insert(mx);
lo = mn + 1;
hi = mx - 1;
}while(lo <= hi && s.size() < N);
}else{
recur(N, 0ll, (long long)1e18);
}
vector<long long> v;
for(long long x : s) v.push_back(x);
mx = 0ll;
for(int i = 1; i < N; i++){
mx = max(mx, v[i] - v[i-1]);
}
return mx;
return 0;
}
Compilation message (stderr)
gap.cpp: In function 'void recur(const int&, long long int, long long int)':
gap.cpp:8:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(s.size() == N) return;
~~~~~~~~~^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
}while(lo <= hi && s.size() < N);
~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |