# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629913 | hy_1 | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
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>
#define ll long long
using namespace std;
long long findGap(int T, int n){
vector<ll> arr;
ll l =0 , r = 1e18;
while(arr.size() < n){
ll mn , mx;
MinMax(l , r , &mn , &mx);
arr.push_back(mn);
if(mn != mx){
arr.push_back(mx);
}
l = mn + 1;
r = mxn -1;
}
ll ans = 0;
sort(arr.begin() , arr.end());
for(int i =1; i<n; i++){
ans = max(ans , arr[i] - arr[i-1]);
}
return ans;
}