이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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){
ll res=-1;vector<ll>ans;
if(T==1){ans.resize(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]);
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);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);}
for(int i=0;i<int(ans.size())-1;i++)umax(res,ans[i+1]-ans[i]);
return max(res,mx-ans.back());
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |