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;
ll minGap,ans; minGap = ans = (ll)ceil((long double)(mxx-mnn)/(N-1));
for(int i = 0; i < N-1; i++) {
MinMax(premx+1, premx+minGap, &mnn, &mxx);
ans = max(ans,mnn-premx);
premx = max(premx,mxx);
}
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |