이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long
long long findGap(int T, int n)
{
ll L = 0, R = 1e18;
if(T == 1) {
vector<ll> p, s;
int cnt = 0;
while(cnt < n) {
ll mn = 0, mx = 0;
MinMax(L, R, &mn, &mx); cnt += 2;
if(mn == -1) break;
p.push_back(mn); s.push_back(mx);
L = mn + 1; R = mx - 1;
}
for(int j = (int)s.size() - 1; j >= 0; j--) p.push_back(s[j]);
ll ans = 0;
for(int j = 1; j < p.size(); j++) ans = max(ans, p[j] - p[j - 1]);
return ans;
}
ll mn = 0, mx = 0, Mx = 0;
MinMax(L, R, &mn, &mx); Mx = mx;
ll x = (mx - mn + n - 1) / n, ans = x;
ll last = mn, cur = mn + 1;
while(cur <= Mx) {
MinMax(cur, cur + x, &mn, &mx);
ans = max(ans, mn - last);
if(mx != -1) last = mx;
cur += x + 1;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int j = 1; j < p.size(); j++) ans = max(ans, p[j] - p[j - 1]);
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |