Submission #541015

#TimeUsernameProblemLanguageResultExecution timeMemory
541015amunduzbaevGap (APIO16_gap)C++17
53.51 / 100
62 ms2260 KiB
#include "bits/stdc++.h" using namespace std; #include "gap.h" #ifndef EVAL #include "grader.cpp" #endif #define ar array typedef long long ll; const ll inf = 1e18; ll findGap(int t, int n){ if(t == 1){ ll l = 0, r = inf, mn, mx; vector<ll> a; while(l <= r){ MinMax(l, r, &mn, &mx); a.push_back(mn); if(mn != mx) a.push_back(mx); l = mn + 1, r = mx - 1; } sort(a.begin(), a.end()); ll res = 0; for(int i=1;i<n;i++){ res = max(res, a[i] - a[i-1]); } return res; } ll l = 0, r = inf, mn, mx; MinMax(l, r, &mn, &mx); ll B = (mx - mn) / n, last = mn, R = mx; ll res = B; for(l=mn;last<R;l += B + 1){ MinMax(l, l + B, &mn, &mx); if(mn == -1) continue; res = max(res, mn - last); last = mx; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...