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>
#include "gap.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;
MinMax(0, (long long)1e18, &mini, &maxi);
long long tmp = maxi - mini - 1;
if(N == 2)return maxi-mini;
long long prev = mini, prev2 = mini, tmp2 = maxi;
for(int i=1;i<=N-1;i++){
long long x = tmp/(N-i);
tmp -= x;
MinMax(prev2 + 1, prev2 + x, &mini, &maxi);
//cout << prev2 + 1 << " " << prev2 + x << " " << mini << " " << maxi << '\n';
if(mini != -1)ans = max(ans, mini - prev), prev = maxi;
prev2 += x;
}
if(maxi != -1)ans = max(ans, tmp2 - maxi);
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |