제출 #409861

#제출 시각아이디문제언어결과실행 시간메모리
409861MasterTasterGap (APIO16_gap)C++14
30 / 100
50 ms1180 KiB
#include "gap.h"
#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second

using namespace std;

long long findGap(int T, int N)
{
    ll minn, maxx;
    MinMax(0LL, 1000000000000000000LL, &minn, &maxx);

    if (N==2) { return maxx-minn; }

    int i=1; int j=N-2;

    ll ress=0;
    while (i<=j)
    {
        ll staromin=minn, staromax=maxx;
        MinMax(minn+1, maxx-1, &minn, &maxx);

        if (j-i==1) { ress=max(ress, maxx-minn); }

        ress=max(ress, max(minn-staromin, staromax-maxx));

        i++; j--;
    }
    return ress;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...