This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint findGap(int T, int N) {
lint res = 0;
if (T == 1) {
vector<lint> X;
lint l = 0, r = (lint) 1e18;
for (int i = 0; i < (N + 1) / 2; i++) {
lint mn, mx;
MinMax(l, r, &mn, &mx);
X.emplace_back(mn);
X.emplace_back(mx);
l = mn + 1;
r = mx - 1;
}
sort(begin(X), end(X));
for (int i = 0; i + 1 < X.size(); i++) {
res = max(res, X[i + 1] - X[i]);
}
}
if (T == 2) {
lint low, high;
MinMax(0, (lint) 1e18, &low, &high) ;
lint BLOCK = ((high - low - 1) / (N - 1)) + 1;
vector<lint> X;
X.emplace_back(low);
for (lint i = low + 1; i < high; i += BLOCK + 1) {
lint mn, mx;
MinMax(i, min(i + BLOCK, high - 1), &mn, &mx);
if (mn != -1 && mx != -1) {
X.emplace_back(mn);
X.emplace_back(mx);
}
}
X.emplace_back(high);
for (int i = 0; i + 1 < X.size(); i++) {
res = max(res, X[i + 1] - X[i]);
}
}
return res;
}
Compilation message (stderr)
gap.cpp: In function 'lint findGap(int, int)':
gap.cpp:24:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i + 1 < X.size(); i++) {
~~~~~~^~~~~~~~~~
gap.cpp:47:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i + 1 < X.size(); i++) {
~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |