제출 #1094286

#제출 시각아이디문제언어결과실행 시간메모리
1094286minggaGap (APIO16_gap)C++17
30 / 100
36 ms1992 KiB
#include "bits/stdc++.h"
#include "gap.h"

using namespace std;

#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 2e18
#define fast_cin()                  \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define out(file) freopen(file, "w", stdout)
#define in(file) freopen(file, "r", stdin)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
// #define int long long
int MOD = 1e9 + 7;

long long findGap(int T, int N) {
    // if(T == 1) {
        long long mn, mx;
        long long lb = 0, rb = 1e18;
        int l = 0, r = N - 1;
        vector<long long> a(N, 0);
        while(l <= r) {
            MinMax(lb, rb, &mn, &mx);
            a[l] = mn, a[r] = mx;
            lb = mn + 1, rb = mx - 1;
            l++,
            r--;
        }
        long long ans = 0;
        for(int i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]);
        return ans;
    // }
    // return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...