제출 #371479

#제출 시각아이디문제언어결과실행 시간메모리
371479BartolMGap (APIO16_gap)C++17
0 / 100
42 ms1364 KiB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

pii query(ll a, ll b) {
    if (a>b) return mp(-1, -1);
    ll x, y;
//    printf("[%lld, %lld]\n", a, b);
    MinMax(a, b, &x, &y);
    return mp(x, y);
}

long long findGap(int T, int N) {
    ll sol=0;
    pll pp=query(0, 1e18);
    N-=2;
    while (N>=1) {
        pll curr=query(pp.X+1, pp.Y-1);
        sol=max(sol, curr.X-pp.X);
        sol=max(sol, pp.Y-curr.Y);
        pp=curr;
        N-=2;
    }
    sol=max(sol, pp.Y-pp.X);

    return sol;
}

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