#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;
ll findGap1(int N)
{
ll lo = 0;
ll hi = 1'000'000'000'000'000'000;
int calls = (N+1)/2;
vector<ll> arr;
for (int x=0; x<calls; x++)
{
ll ai, ani;
MinMax(lo, hi, &ai, &ani);
if (ai!=-1)
{
arr.push_back(ai);
arr.push_back(ani);
lo = ai+1;
hi = ani-1;
}
}
sort(arr.begin(), arr.end());
ll max_diff = 0;
for (int i=0; i<(N-1); i++)
max_diff = max(max_diff, arr[i+1]-arr[i]);
return max_diff;
}
ll findGap(int T, int N)
{
if (T==1)
return findGap1(N);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |