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)
{
ll mn,mx;
MinMax(1,1LL<<60,&mn,&mx);
vector<ll> a(0);
ll ans=-1;
if (T==1){
a.push_back(mn);a.push_back(mx);
while (mn<mx){
MinMax(mn+1,mx-1,&mn,&mx);
if (mn!=-1) a.push_back(mn);
if (mx!=-1) a.push_back(mx);
}
}
else{
ll gmn=mn,gmx=mx,rng=(mx-mn+N-2)/(N-1);
a.push_back(mn);a.push_back(mx);
gmn++;
while (gmn<gmx){
MinMax(gmn,gmn+rng,&mn,&mx);
if (mn!=-1) a.push_back(mn);
if (mx!=-1) a.push_back(mx);
gmn+=rng;
}
}
sort(a.begin(),a.end());
for (int i=1;i<a.size();i++){
ans=max(ans,a[i]-a[i-1]);
}
return ans;
return 0;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i=1;i<a.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |