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;
long long findGap(int T, int N)
{
vector<long long> ujung;
long long mn,mx;
MinMax(0,1e18,&mn,&mx);
//mn+1...mx-1 bagi N-1 segment
//PHP ada 1 segment yang kosong
//Gap maximumnya beda segment
long long bagi=(mx-mn-1)/(N-1);
int sisa=(mx-mn-1)%(N-1);
long long ki=mn+1,last=mn,ujungka=mx,ans=0;
for(int i=1;i<N;i++){
if(i<=sisa){
MinMax(ki,ki+bagi,&mn,&mx);
ki+=(bagi+1);
}
else{
MinMax(ki,ki+bagi-1,&mn,&mx);
ki+=bagi;
}
if(mn!=-1){
ans=max(ans,mn-last);
last=mx;
}
}
ans=max(ans,ujungka-last);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |