제출 #1220329

#제출 시각아이디문제언어결과실행 시간메모리
1220329jer033Gap (APIO16_gap)C++20
0 / 100
32 ms2240 KiB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;

ll findGap1(int N)
{
    ll lo = 0;
    ll hi = 1'000'000'000'000'000'000;
    int calls = (N+1)/2;
    vector<ll> arr;
    while (calls--)
    {
        ll ai, ani;
        MinMax(lo, hi, &ai, &ani);
        arr.push_back(ai);
        arr.push_back(ani);
        lo = ai+1;
        hi = ani-1;
    }
    sort(arr.begin(), arr.end());
    ll max_diff = 0;
    for (int i=0; i<(N-1); i++)
        max_diff = max(max_diff, arr[i+1]-arr[i]);
    return max_diff;
}

ll findGap(int T, int N)
{
    if (T==1)
        return findGap1(N);
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...