Submission #32340

#TimeUsernameProblemLanguageResultExecution timeMemory
32340WhipppedCreamGap (APIO16_gap)C++14
100 / 100
86 ms5140 KiB
#include <bits/stdc++.h> #ifdef atom #include "grader.cpp" #else #include "gap.h" #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vvi vector< vi > #define vii vector< ii > #define mp make_pair #define pb push_back long long findGap(int T, int n) { ll left, right; MinMax(0, 1e18, &left, &right); ll best = 0; if(T == 1) { ll lmin = left, lmax = right; for(int i = 2; i< n; i+= 2) { ll mmin, mmax; MinMax(lmin+1, lmax-1, &mmin, &mmax); best = max(best, mmin-lmin); best = max(best, lmax-mmax); lmin = mmin; lmax = mmax; } best = max(best, lmax-lmin); } else { ll last = left; ll sz = (right-left+n-1)/n; for(ll s = left+1, e = left+sz, i = 0; i< n; s+= sz, e+=sz) { if(e>= right) e = right-1; if(s> e) break; ll mmin, mmax; MinMax(s, e, &mmin, &mmax); if(mmin != -1) { best = max(best, mmin-last); last = mmax; } } best = max(best, right-last); } return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...