제출 #1328299

#제출 시각아이디문제언어결과실행 시간메모리
1328299nguyenkhangninh99Gap (APIO16_gap)C++20
30 / 100
36 ms2308 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll findGap(int t, int n){
    ll ans = 0;
    if(t == 1){
        vector<ll> a;
        ll l = 1, r = 1e18;
        while(a.size() < n){
            ll mn = 1e18, mx = -1e18;
            MinMax(l, r, &mn, &mx);
            if(mn == -1) break;
            a.push_back(mn);
            a.push_back(mx);
            l = mn + 1;
            r = mx - 1;
        }
        sort(a.begin(), a.end());
        for(int i = 0; i + 1 < a.size(); i++) ans = max(ans, a[i + 1] - a[i]);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...