Submission #959555

#TimeUsernameProblemLanguageResultExecution timeMemory
959555MinaRagy06Gap (APIO16_gap)C++17
33.25 / 100
39 ms3360 KiB
#include <bits/stdc++.h> #include "gap.h" #ifdef MINA #include "grader.cpp" #endif using namespace std; #define ll long long const ll inf = 1e18; ll findGap(int t, int n) { ll cur, mx; MinMax(0, inf, &cur, &mx); if (n == 2) { return mx - cur; } if (n == 3) { ll s = cur, e = mx; ll md; MinMax(s + 1, e - 1, &md, &cur); return max(md - s, e - md); } mx = 1; while (cur + mx + 1 < inf) { ll len = mx + 1, s = -1, e = -1; while (len < inf && e == -1) { MinMax(cur + 1, min(cur + len, inf), &s, &e); len *= 2; } if (s != -1) { mx = max(mx, s - cur); } if (e != -1) { cur = e; } else { cur = inf + 1; } } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...