제출 #399175

#제출 시각아이디문제언어결과실행 시간메모리
399175dxz05Gap (APIO16_gap)C++14
8.81 / 100
812 ms1864 KiB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 555555;

typedef long long ll;
ll a[MAXN];

long long findGap(int SUBTASK, int n){
    if (SUBTASK == 1) return 0;
    a[0] = -1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 60; j++){
            ll x = a[i - 1] + (1ll << j);
            ll mn, mx;
            MinMax(a[i - 1] + 1, x, &mn, &mx);
            if (mn != -1){
                a[i] = mn;
                break;
            }
        }
    //    cout << a[i] << ' ';
    }

    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...