이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
*/
#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-3)/(n-2);
int frm = 2;
vector<int> all;
all.pb(st);
all.pb(en);
REP(i,n-2){
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... |