Submission #21929

#TimeUsernameProblemLanguageResultExecution timeMemory
21929RezwanArefin01Gap (APIO16_gap)C++14
30 / 100
56 ms5144 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long findGap(int T, int N) { if(T==1) { ll pmn, pmx, mn, mx, ret = 0; MinMax(0, (ll)1e18+10, &pmn, &pmx); for(int i=1; i<(N+1)/2; i++) { MinMax(pmn+1, pmx-1, &mn, &mx); ret = max(ret, mn - pmn); ret = max(ret, pmx - mx); pmn = mn, pmx = mx; } ret = max(ret, pmx - pmn); return ret; } else { ll st, ed, ret = 0; MinMax(0, (ll)1e18+10, &st, &ed); ll gap = (ed - st) / (N - 1); ll prev = st; for(int i=st+1, j = i + gap; j <= ed; i = j + 1, j = i + gap) { ll mn, mx; MinMax(i, j, &mn, &mx); if(mn != -1) { ret = max(ret, mn - prev); prev = mx; } } ret = max(ret, ed - prev); return ret; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...