이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back
void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}
template<typename T,typename V>
void PRINT(pair<T,V>& x){
cerr<<"{";
PRINT(x.fi);
cerr<<",";
PRINT(x.se);
cerr<<"}";
}
template<typename T>
void PRINT(T &x){
int id=0;
cerr<<"{";
for(auto _i:x){
cerr<<(id++ ? "," : "");
PRINT(_i);
}
cerr<<"}";
}
void _PRINT(){
cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
PRINT(h);
if(sizeof...(t)) cerr<<", ";
_PRINT(t...);
}
#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)
long long findGap(int T, int N){
if(T==1){
ll l=1,r=LINF;
vector<ll> a;
for(int i=1;i<=(N+1)/2;i++){
ll mn,mx;
MinMax(l,r,&mn,&mx);
a.pb(mn); a.pb(mx);
l=mn+1,r=mx-1;
}
sort(all(a));
ll res=0;
for(int i=0;i<sz(a)-1;i++){
res=max(res,a[i+1]-a[i]);
}
return res;
}
else{
vector<ll> a;
ll mn,mx;
MinMax(1,LINF,&mn,&mx);
ll l=mn,r=mx;
a.pb(l); a.pb(r);
l++,r--;
ll seg_sz=(r-l+1)/(N-2);
ll cnt=(r-l+1)%(N-2);
vector<pll> segs;
ll l1,r1=l-1;
for(int i=1;i<=N-2;i++){
l1=r1+1;
if(cnt){
r1=l1+seg_sz;
cnt--;
}
else r1=l1+seg_sz-1;
ll mn,mx;
MinMax(l1,r1,&mn,&mx);
if(mn!=-1){
a.pb(mn); a.pb(mx);
}
}
ll res=0;
sort(all(a));
for(int i=0;i<sz(a)-1;i++){
res=max(res,a[i+1]-a[i]);
}
return res;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |