이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <vector>
#include <iostream>
#include <assert.h>
#include <algorithm>
using namespace std;
typedef long long ll;
ll INF=1e18;
ll S=1e15;
ll K=2;
ll x,y;
vector<ll> V;
void F(ll a, ll b){
MinMax(a,b,&x,&y);
if(x==-1)return;
if(a==b)
V.push_back(a);
else{
ll p=(b-a+K-1)/K;
for(ll i=a;i<=b;i+=p)
F(i,min(i+p-1,b));
}
}
long long findGap(int T, int N)
{
if(T==1){
y=INF;
for(int i=0;i<(N+1)/2;i++){
MinMax(x,y,&x,&y);
if(x==-1)break;
V.push_back(x);
V.push_back(y);
x++;
y--;
if(x>y)break;
}
sort(V.begin(),V.end());
x=0;
for(int i=0;i<V.size()-1;i++)
x=max(x,V[i+1]-V[i]);
return x;
}
MinMax(INF,INF,&x,&y);
if(x!=-1)
V.push_back(INF);
for(ll i=0;i<INF;i+=S)
F(i,i+S-1);
sort(V.begin(),V.end());
x=0;
for(int i=0;i<V.size()-1;i++)
x=max(x,V[i+1]-V[i]);
return x;
}
/*
1 6
1 2 5 7 8 12
*/
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:50:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size()-1;i++)
~^~~~~~~~~~~
gap.cpp:67:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size()-1;i++)
~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |