이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
//#include "grader.cpp"
using namespace std;
typedef long long ll;
const ll inf = 1e18;
vector <ll> a;
ll ans = 0;
pair <ll, ll> ask (ll l, ll r) {
if (l > r) return {-1, -1};
ll mn = l, mx = r;
MinMax(l, r, &mn, &mx);
return {mn, mx};
}
void recurse (ll l, ll r) {
if (l == r) {
return;
}
ll mid = (l + r) / 2;
auto g = ask(l + 1, mid);
if (g.first != -1) recurse(g.first, g.second);
auto h = ask(mid + 1, r - 1);
if (h.first != -1) recurse(h.first, h.second);
if (g.second != -1 && h.first != -1) ans = max(ans, h.first - g.second);
if (g.first != -1) ans = max(ans, g.first - l);
if (h.second != -1) ans = max(ans, r - h.second);
if (g.first == -1 && h.first == -1) ans = max(ans, r - l);
if (g.first != -1 && h.first == -1) ans = max(ans, r - g.second);
if (g.first == -1 && h.first != -1) ans = max(ans, h.first - l);
}
ll findGap (int t, int n) {
a.clear(); ans = 0;
auto g = ask(0, inf);
recurse(g.first, g.second);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |