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<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include "gap.h"
using namespace std;
#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#undef int
long long findGap(int T, int N)
{
#define int long long
if(T == 1){
vector<int> all;
int curl = 1;
int curr = 1e18;
int dd = 0;
while(curl <= curr and dd < N){
int whAt1 = 0;
int whAt2 = 0;
MinMax(curl,curr,&whAt1,&whAt2);
all.pb(whAt1);
if(whAt1 != whAt2)all.pb(whAt2);
dd += 1+(whAt1 != whAt2);
curl = whAt1+1;
curr = whAt2-1;
}
sort(all(all));
int ans = 0;
REP(i,N-1){
ans = max(ans,all[i+1]-all[i]);
}
return ans;
}
else{
int st,en;
int n= N;
MinMax((int)1,(int)1e18,&st,&en);
if(n == 2)return en-st;
int rangesize = (en-st-1+n-2)/(n-1);
int frm = st+1;
vector<int> all;
all.pb(st);
all.pb(en);
REP(i,n){
int oo1,oo2;
if(frm >= en)break;
MinMax(frm,min(frm+rangesize-1,en-1),&oo1,&oo2);
all.pb(oo2);
all.pb(oo1);
frm += rangesize;
}
int ans = 0;
sort(all(all));
REP(i,(int)all.size()-1){
ans = max(ans,all[i+1]-all[i]);
}
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |