Submission #384990

#TimeUsernameProblemLanguageResultExecution timeMemory
384990thecodingwizardGap (APIO16_gap)C++11
57.64 / 100
65 ms1400 KiB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

#define f first
#define s second
#define ll long long
#define ii pair<ll, ll>

ii get(ll a, ll b) {
    b = min(b, (ll)1e18);
    ii x;
    MinMax(a, b, &x.f, &x.s);
    return x;
}

long long findGap(int T, int N)
{
    ii boundary = get(1, 1e18);
    ll block = (boundary.s-boundary.f)/(N-1);
    ll prev = boundary.f;

    ll ans = 0;
    for (ll cur = boundary.f + 1; cur < boundary.s; cur += block) {
        ii thing = get(cur, cur+block);
        if (thing.f == -1) continue;
        ans = max(ans, thing.f - prev);
        prev = thing.s;
    }

    ans = max(ans, boundary.s - prev);

    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...