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"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
typedef long long ll;
const ll B=1e18;
long long findGap(int T, int N){
if(T==1){
vector<ll>ans(N);
MinMax(0LL,B,&ans[0],&ans[N-1]);
for(int l=1,r=N-2;l<=r;l++,r--)
MinMax(ans[l-1]+1,ans[r+1]-1,&ans[l],&ans[r]);
ll res=-1;
for(int i=0;i<N-1;i++)
umax(res,ans[i+1]-ans[i]);
return res;
}
ll a,b,mn,mx;
MinMax(0LL,B,&mn,&mx);
ll d=(mx-mn-1)/(N-1);
vector<ll>ans;ans.pb(mn);
for(ll l=mn+1;l<mx;l+=d+1){
MinMax(l,min(l+d,mx-1),&a,&b);
if(~a)
ans.pb(a),ans.pb(b);
}ans.pb(mx);
ll res=-1;
for(int i=0;i<int(ans.size())-1;i++)
umax(res,ans[i+1]-ans[i]);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |