Submission #1227004

#TimeUsernameProblemLanguageResultExecution timeMemory
1227004cpdreamerGap (APIO16_gap)C++20
0 / 100
31 ms1864 KiB
#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 1e9+7;
#define F first
#define pb push_back
#define S second
#define P pair
#define V vector
#define all(v) v.begin(), v.end()

long long findGap(int T, int N)
{
    ll v1=-1,v2=1e18+1;
    int p1=0,p2=N-1;
    ll A[N];
    while (p1<=p2) {
        ll mn,mx;
        MinMax(v1+1,v2-1,&mn,&mx);
        if (mn==-1) {
            break;
        }
        v1=mn,v2=mx;
        A[p1]=v1,A[p2]=v2;
        p1++,p2--;
    }
    ll ans=0;
    for (int i=0;i<N-1;i++) {
        ans=max(ans,A[i+1]-A[i]);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...