Submission #399169

#TimeUsernameProblemLanguageResultExecution timeMemory
399169dxz05Gap (APIO16_gap)C++14
0 / 100
3099 ms1880 KiB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 555555;

typedef long long ll;
ll a[MAXN];

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

ll get_rand(ll l, ll r){
    return l + rng() % (r - l + 1);
}

long long findGap(int SUBTASK, int n){
    a[0] = -1;
    for (int i = 1; i <= n; i++){
        ll x = a[i - 1] + 1;
        while (true){
            x = get_rand(x, 1e18);
            ll mn, mx;
            MinMax(a[i - 1] + 1, x, &mn, &mx);
            if (mn != -1){
                a[i] = mn;
                break;
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i < n; i++){
        ans = max(ans, a[i + 1] - a[i]);
    }

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