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>
using namespace std;
#define intt long long
#define fore(i , n) for(int i = 0 ; i < n; i++)
#define forr(i , x ,y) for(int i = x; i <= y;i++)
void MinMax(intt s , intt t , intt *mn , intt *mx);
long long findGap(int T, int N)
{
intt mn , mx;
MinMax(0ll , 1LL * 1e18 , &mn , &mx);
intt gmn = mn , gmx = mx;
intt d = (mx - mn + N - 2)/((N - 1));
vector<intt> MinB(N , -1) , MaxB(N , -1);
fore(i , N - 1)
{
intt lt = i * d + gmn , rt = (i + 1)*d + gmn - 1;
MinMax(lt , rt , &mn , &mx);
MinB[i] = mn;
MaxB[i] = mx;
}
if((N - 1) * d + gmn <= gmx)
MinB[N - 1]= MaxB[N - 1] = gmx;
intt prv = MaxB[0];
intt ans = (intt)d;
forr(i , 1 , N - 1)
{
if(MinB[i] == -1)
continue;
ans = max(ans , MaxB[i] - MinB[i]);
ans= max(ans , MinB[i] - prv);
prv = MaxB[i];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |