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 i64=long long;
const i64 INF=1e18;
long long findGap(int test, int n)
{
i64 rez=0;
if (test == 0)
{
i64 l=1,r=INF;
std::vector<int>a;
for(int i=0;i<n/2+1,l<=r;i++)
{
MinMax(l,r,&l,&r);
a.push_back(l);
a.push_back(r);
l++;
r--;
}
sort(a.begin(),a.end());
rez=0;
i64 last=a[0];
for(auto &c:a)
{
rez=std::max(rez , c-last);
last=a[0];
}
}
else
{
i64 l,r;
MinMax(1,INF,&l,&r);
if(l==r)
{
return 0;
}
const i64 at_least_gap=(r-l+n-2)/(n-1);
rez=at_least_gap;
for(i64 i=l,last=l;i<=r;i+=at_least_gap)
{
i64 mn,mx;
MinMax(i,i+at_least_gap-1,&mn,&mx);
if(mn!=-1)
{
rez=std::max(rez , mn-last);
last=mx;
}
}
}
return rez;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:22: warning: left operand of comma operator has no effect [-Wunused-value]
12 | for(int i=0;i<n/2+1,l<=r;i++)
| ~^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |