제출 #1154991

#제출 시각아이디문제언어결과실행 시간메모리
1154991browntoadGap (APIO16_gap)C++20
58.08 / 100
45 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){
	ll L, R;
	MinMax(0, 1e18, &L, &R);

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

    ll gapsize = dif/(N-1) + (dif%(N-1)>0) - 1;
    for (ll i = 1; i < R; i += gapsize+1){
        ll rptr = min(R-1, 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...