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;
long long B[100005];
long long findGap(int T, int N)
{
if(T == 1){
long long ans = 0, mini, maxi;
B[N+1] = (long long)1e18 + 5, B[0] = -1;
int j = N;
for(int i=1;i<=j;i++){
//cout << B[i-1] << " " << B[j+1] << '\n';
MinMax(B[i-1]+1, B[j+1]-1, &mini, &maxi);
//cout << mini << '\n';
B[i] = mini, B[j] = maxi;
//cout << *mini << " " << *maxi << '\n';
j--;
}
for(int i=1;i<N;i++)ans = max(ans, B[i+1] - B[i]);
return ans;
}
else{
long long ans = 0, mini, maxi;
B[N+1] = (long long)1e18 +1;
for(int i=N;i>=1;i--){
long long s = 0, e = B[i+1] - 1, ans2 = s;
while(s <= e){
long long m = (s + e)/2;
MinMax(m, B[i+1]-1, &mini, &maxi);
if(mini != -1)ans2 = mini, s = mini + 1;
else e = m - 1;
}
B[i] = ans2;
}
for(int i=1;i<N;i++)ans = max(ans, B[i+1] - B[i]);
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |