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<vector>
using namespace std;
typedef long long lld;
long long maximo(lld a, lld b){
if(a<b)return b;
return a;
}
long long minimo(lld a, lld b){
if(a<b)return a;
return b;
}
long long findGap(int T, int N)
{
if(T==1){
return 0;
}
lld min,max;
MinMax(0,1000000000000000000,&min,&max);
lld Maxlength=(max-min-1)/N;
Maxlength++;
vector<lld> candidates;
candidates.push_back(min);
for(lld i=min+1;i<max;i+=Maxlength){
lld s=i;
lld t=minimo(i+Maxlength-1,max);
lld c1,c2;
MinMax(s,t,&c1,&c2);
if(c1!=-1){
candidates.push_back(c1);
candidates.push_back(c2);
}
}candidates.push_back(max);
for(int i=0;i<candidates.size()-1;i++){
Maxlength=maximo(Maxlength,candidates[i+1]-candidates[i]);
}
return Maxlength;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:35:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<candidates.size()-1;i++){
~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |