Submission #1155428

#TimeUsernameProblemLanguageResultExecution timeMemory
1155428SangGap (APIO16_gap)C++20
59.04 / 100
44 ms1188 KiB
#ifndef _Pbrngw_
#include "gap.h"
#endif // _Pbrngw_
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define task "kbsiudthw"

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;

const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 2277;


long long findGap(int T, int N)
{
    long long A, B, C1, C2;
    MinMax(0, 1e18, &A, &B);
    if (N == 2) return B - A;
    long long block = (B - A - 1)/(N - 2);
    long long last = A, ans = 0;
    for (long long i = A+1; i < B; i += block){
        long long x, y;
        MinMax(i, min(B - 1, i + block - 1), &x, &y);
        if (x == -1) continue;
        ans = max(ans, x - last);
        last = y;
    }
    ans = max(ans, B - last);
    return ans;
}

#ifdef _Pbrngw_
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }

    return 0;
}
#endif // _Pbrngw_

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