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;
typedef long long ll;
ll findGap(int T, int N) {
if(T==1) {
vector<ll> a(N);
int l = 0, r = N-1;
ll mnn = 0, mxx = 1e18;
while(l <= r) {
MinMax(mnn, mxx, &a[l], &a[r]);
mnn = a[l]+1; mxx = a[r]-1;
l++; r--;
}
ll ans = 0;
for(int i = 1; i < N; i++) {
ans = max(ans, a[i]-a[i-1]);
}
return ans;
}
else {
ll mnn, mxx, premx;
MinMax(0, 1e18, &mnn, &mxx);
premx = mnn;
const ll MX = mxx;
ll minGap,ans; minGap = ans = (ll)ceil((long double)(mxx-mnn)/(N-1));
ll s;
//cout <<minGap<<endl;
for(s = mnn+1; s < MX; s+=minGap) {
MinMax(s, s+minGap, &mnn, &mxx);
//cout << s << " " << mnn << " " << mxx << ' '<<premx<<endl;
ans = max(ans, mnn-premx);
premx = max(premx,mxx);
//cout << s+minGap << ' '<<mxx<<endl;
}
ans = max(ans, mxx-premx);
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |