이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
using ull = unsigned long long;
using ll = long long;
using namespace std;
constexpr ll INF = 1e18;
vector<ll> arr;
#ifdef HOME
void MinMax(ll a, ll b, ll* mn, ll* mx) {
*mn = INF;
*mx = -INF;
for (auto itr : arr) {
if (itr >= a && itr <= b) {
*mn = min(*mn, itr);
*mx = max(*mx, itr);
}
}
if (*mn == INF) {
*mn = -1;
}
if (*mx == -INF) {
*mx = -1;
}
}
#else
#include "gap.h"
#endif
pair<ll, ll> Query(ll a, ll b) {
ll mn, mx;
MinMax(a, b, &mn, &mx);
return {mn, mx};
}
ll findGap(int T, int N) {
pair<ll, ll> res = Query(0, INF);
ll a1 = res.first;
ll an = res.second;
ll step = (an - a1 + N - 2) / (N - 1);
ll answer = 0;
ll curr = a1;
while (curr < an) {
int x = 0;
do {
x++;
res = Query(curr + 1, curr + step * x);
if (res.second != -1) {
break;
}
} while (true);
answer = max(answer, res.first - curr);
curr = res.second;
}
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |