제출 #1287549

#제출 시각아이디문제언어결과실행 시간메모리
1287549khoavn2008Gap (APIO16_gap)C++17
0 / 100
40 ms3232 KiB
#ifndef KHOA
#include "gap.h"
#endif // KHOA

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define FOR(i,l,r) for(int i = (l), _r = (r); i <= _r; i++)
#define FORNG(i,r,l) for(int i = (r), _l = (l); i >= _l; i--)
#define REP(i,r) for(int i = 0, _r = (r); i < _r; i++)
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define size(v) ((ll)(v).size())
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)

const ll MOD = 1e9 + 7, N = 2e5 + 10, INF = 2e18, LOG = 21;
ll a[N];

#ifdef KHOA
ll A[N] = {-2008, };
void MinMax(ll x,ll y,ll *z,ll *t){
    bool ok = 0;
    FOR(i,1,10){
        if(x <= a[i] && !ok){
            *z = a[i];
            ok = 1;
        }
        if(a[i] <= y)*t = a[i];
    }
}
#endif

ll findGap(int T, int n){
    ll L = 0, R = 1e18;
    ll lo, hi;
    MinMax(L, R, &lo, &hi);
    L = lo, R = hi;
    ll sz = (R - L + n - 1) / (n - 1);
    ll last = L, ans = -INF;
    ll i;
    for(i = lo + 1; i + sz < R; i += sz){
        MinMax(i, i + sz, &lo, &hi);
        if(lo != -1){
            ans = max(ans, lo - last);
            last = hi;
        }
    }
    if(lo != -1)ans = max(ans, R - last);
    return ans;
}

#ifdef KHOA
int main(){
    FOR(i,1,10)a[i] = i * 10,cerr<<a[i]<<' ';
    cerr<<endl;
    cout<<findGap(1, 10);

}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...