Submission #564952

#TimeUsernameProblemLanguageResultExecution timeMemory
564952Spade1Gap (APIO16_gap)C++14
0 / 100
49 ms1864 KiB
#include<bits/stdc++.h>
#include "gap.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

const int NN = 1e5 + 10;

ll a[NN];

ll findGap(int T, int N) {
    ll mn, mx;
    ll _max = 0;
    MinMax(0LL, (ll)1e18, &mn, &mx);
    a[1] = mn, a[N] = mx;
    int i = 1;
    while (1) {
        MinMax(a[i]+1, a[N-i+1]-1, &mn, &mx);
        if (mn == -1 && mx == -1) break;
        if (mn == mx) {
            a[i+1] = mn;
            break;
        }
        a[i+1] = mn;
        a[N-i] = mx;
        i++;
        if(i > N-i) break;
    }

    for (int i = 1; i < N; ++i) {
        _max = max(_max, a[i+1]-a[i]);
    }
    return _max;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...