# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347977 | joylintp | Gap (APIO16_gap) | C++17 | 57 ms | 1772 KiB |
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;
long long findGap(int T, int N)
{
long long l, r, ans = 0;
MinMax(0, 1000000000000000000, &l, &r);
queue<pair<long long, long long>> q;
q.push({l, r});
while (!q.empty())
{
l = q.front().first, r = q.front().second, q.pop();
if (r - l <= ans)
continue;
if (r - l <= 1)
ans = max(ans, r - l);
else if (r - l == 2)
{
long long tl, tr;
MinMax(l, l + 1, &tl, &tr);
ans = max(ans, 2LL - (tr == l + 1));
}
else if (r - l == 3)
{
long long tl, tr;
MinMax(l + 1, r - 1, &tl, &tr);
ans = max(ans, 3LL - (tl == l + 1) - (tr == r - 1));
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |