Submission #1155002

#TimeUsernameProblemLanguageResultExecution timeMemory
1155002browntoadGap (APIO16_gap)C++20
83.51 / 100
44 ms3256 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RREP1(i, n) for (int i = (n); i >= 1; i--)
#define REP1(i, n) FOR(i, 1, n+1)
#define pii pair<int, int>
#define ppi pair<pii, int>
#define pip pair<int, pii>
// #define f first
// #define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define endl '\n'
#define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
// #include "grader.cpp" // remove this later
#include "gap.h"

ll findGap(int T, int N){
    vector<ll> pts;
    if (T == 1){
        ll L = 0, R = 1e18;
        REP(i, (N+1)/2){
            ll pL = L, pR = R;
            MinMax(pL, pR, &L, &R);
            pts.pb(L);
            pts.pb(R);
            L++;
            R--;
        }
        sort(ALL(pts));
    }
    else{
        ll L, R;
        MinMax(0, 1e18, &L, &R);

        ll dif = R-L;
        pts.pb(L);

        ll gapsize = dif/(N-1) + (dif%(N-1)>0) - 1;
        for (ll i = L; i <= R; i += gapsize+1){
            ll rptr = min(R, i+gapsize), lptr = i;
            ll tl, tr;
            MinMax(lptr, rptr, &tl, &tr);
            if (tl != -1){
                pts.pb(tl);
                pts.pb(tr);
            }
        }
        pts.pb(R);

    }

    ll ans = 0;
    REP(i, SZ(pts)-1){
        ans = max(ans, pts[i+1]-pts[i]);
    }
    return ans;

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