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>
long long findGap(int T, int N)
{
long long arr[111111];
long long mn, mx;
long long tmp;
long long maximum;
long long high=1e18, low=0;
if(T==1)
{
for(int i=1;i<=N/2;i++)
{
MinMax(low,high,&mn,&mx);
arr[i]=mn;
arr[N-i+1]=mx;
low=mn+1;
high=mx-1;
}
if(N%2==1)
{
MinMax(low,high,&mn,&mx);
arr[N/2+1]=mn;
}
long long answer=0;
for(int i=2;i<=N;i++)
answer=std::max(answer,arr[i]-arr[i-1]);
return answer;
}
else
{
long long answer=0;
MinMax(low,high,&mn,&mx);
tmp=mn;
maximum=mx;
long long sz;
low=mn+1;
high=mx-1;
sz=(mx-mn+N-1)/N;
high=low+sz;
for(int i=0;i<N;i++)
{
MinMax(low,high,&mn,&mx);
low+=sz;
high+=sz;
if(mn==-1)
continue;
answer=std::max(answer,mn-tmp);
tmp=mx;
}
return answer;
}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:15: warning: variable 'maximum' set but not used [-Wunused-but-set-variable]
9 | long long maximum;
| ^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |