이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include "bits/stdc++.h"
using namespace std;
long long findGap(int T, int N) {
long long ret = 0;
vector<long long> a(N + 1);
MinMax(0, LLONG_MAX, &a[1], &a[N]);
for (int i = 1; i < N - 1; ++i) {//find i + 1
if (a[i] == a[N]) {
break;
}
long long s = (a[N] - a[i] + N - i - 1) / (N - i) - 1;
if (s == 0) {
break;
}
long long z = 0;
MinMax(a[i] + 1, a[i] + s, &z, &z);
if (z == -1) {
long long t = 0;
for (int j = 60; j >= 0; --j) {
if ((1LL << j) > a[N]) {
continue;
}
MinMax(a[i] + 1, a[i] + t + (1LL << j), &z, &z);
if (z == -1) {
t += (1LL << j);
}
}
ret = max(ret, t + 1);
a[i + 1] = a[i] + t + 1;
} else {
a[i + 1] = z;
}
}
if (a[N - 1] != 0) {
ret = max(ret, a[N] - a[N - 1]);
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |