이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
long long findGap(int T, int N){
if(T == 1){
ll low = -1, high = (ll)1e18 + 1;
vector<ll> C(N);
int L = 0, R = N - 1;
for(int i = 0 ; i < (N + 1) / 2; i ++ ){
MinMax(low + 1, high - 1, &low, &high);
C[L] = low;
C[R] = high;
L ++ ;
R -- ;
}
ll res = 0;
for(int i = 1; i < N; i ++ ){
res = max(res, C[i] - C[i - 1]);
}
return res;
}
ll low=0, high=0;
ll lim = (ll)1e18;
MinMax(0ll, lim, &low, &high);
ll S = (high - low + (N - 1) - 1) / (N - 1); // the gap is atleast S
ll gl = low + 1;
ll gr;
vector<ll> in;
in.push_back(low);
if(N >= 3){
ll ca, cb;
while(gl <= high){
gr = min(high - 1, gl + S);
MinMax(gl, gr, &ca, &cb);
gl += S + 1;
if(ca == -1) continue;
in.push_back(ca);
in.push_back(cb);
}
}
in.push_back(high);
ll res = 0;
for(int i = 1; i < in.size(); i ++ ){
res = max(res, in[i] - in[i - 1]);
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i = 1; i < in.size(); i ++ ){
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |