# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
407436 | Blobo2_Blobo2 | Gap (APIO16_gap) | C++14 | 3099 ms | 1984 KiB |
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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N){
long long arr[N];
if(T==1){
long long idx=0,mx,mn,l=0,r=1e18;
for(int i=0;i<N/2+(N%2);i++){
MinMax(l,r,&mn,&mx);
arr[i]=mn;
arr[N-i-1]=mx;
l=mn+1;
r=mx-1;
}
}
else{
long long idx=0,mx,mn,l=0,r=1e18;
MinMax(l,r,&mn,&mx);
l=mn;
r=mx;
long long extra=(r-l+N-2)/(N-1);
for(int i=l+1;i<r;){
MinMax(i,i+extra-1,&mn,&mx);
if(mx!=-1){
i=mx+1;
continue;
}
for(int j=2;;j++){
MinMax(i,i+j*extra-1,&mn,&mx);
if(mn!=-1){
extra=mn-i+1,i=mx+1;
break;
}
}
}
return extra;
}
long long ans=0;
for(int i=0;i<N-1;i++)
ans=max(ans,arr[i+1]-arr[i]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |