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>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#include "gap.h"
typedef long long ll;
vector<ll> a;
void so(ll l, ll r, int n){
ll mn = 1, mx = 1;
MinMax(l, r, &mn, &mx);
if(mn == -1)return;
a.pb(mn);
if(mx != mn)a.pb(mx);
if(mn == mx || a.size() >= n)return;
l = mn+1;
r = mx-1;
ll m = (r+l)>>1;
so(l, m, n);
so(m+1, r, n);
}
long long findGap(int t, int n)
{
so(0, 1e18, n);
sort(all(a));
ll ans = 1;
for(int i = 1; i < a.size(); i++)
ans = max(ans, a[i] - a[i-1]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'void so(ll, ll, int)':
gap.cpp:20:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(mn == mx || a.size() >= n)return;
| ~~~~~~~~~^~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i = 1; i < a.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |