Submission #106947

#TimeUsernameProblemLanguageResultExecution timeMemory
106947maksim_gaponovGap (APIO16_gap)C++14
30 / 100
105 ms1400 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll const int MAX = 1e18; int findGap(signed T, signed N) { // cout << T << ' ' << N << endl; int l = 0; int r = MAX; int CNT = 0; MinMax(l, r, &l, &r); ++CNT; int ans = 0; int step = 1; while (r != l) { if (2 * step == N || r - l == 1) { ans = max(ans, r - l); break; } int nl; int nr; MinMax(l + 1, r - 1, &nl, &nr); ++CNT; if (nl != -1) { ans = max(ans, r - nr); ans = max(ans, nl - l); } else { ans = max(ans, r - l); } step++; r = nr; l = nl; // cout << r << ' '; } // cout << endl; // assert(2 * CNT <= N + 1); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...