제출 #541085

#제출 시각아이디문제언어결과실행 시간메모리
541085amunduzbaevGap (APIO16_gap)C++17
30 / 100
59 ms2308 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; for(int i=0;i<=n/2 && (int)a.size() < n;i++){ MinMax(l, r, &mn, &mx); if(mn == -1) break; a.push_back(mn); a.push_back(mx); l = mn + 1, r = mx - 1; } sort(a.begin(), a.end()); ll res = 0; for(int i=1;i<(int)a.size();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 - 1) / n, last = mn, R = mx; ll res = B, cnt = 1; for(l=mn, r=l+B;cnt < n;l=r+1, r=l+B){ MinMax(l, r, &mn, &mx); cnt++; if(mn == -1 || mx == -1) continue; res = max(res, mn - last); last = mx; } res = max(res, R - last); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...