Submission #321105

#TimeUsernameProblemLanguageResultExecution timeMemory
321105MetBGap (APIO16_gap)C++14
90.00 / 100
83 ms2020 KiB
#include "gap.h" #include <bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; ll findSmall(int N) { vector <ll> v (N); ll mn, mx; MinMax (1, 1e18, &mn, &mx); ll s = mn, e = mx; v[0] = s, v[N-1] = e; int l = 0, r = N - 1; while (l + 1 < r) { MinMax(v[l] + 1, v[r] - 1, &s, &e); v[++l] = s, v[--r] = e; } for (int i = 1; i < N; i++) { v[i-1] = v[i] - v[i-1]; } return *max_element(v.begin(), v.end() - 1); } ll findGap(int T, int N) { if (T == 1) { return findSmall(N); } ll mn, mx; MinMax (1, 1e18, &mn, &mx); ll s = mn, e = mx; ld d = (ld) (mx - mn - 2) / N; ld l = mn + 1, r = mn + 1 + d; ll gap = 0, mx_old = mn; for (int i = 0; i < N - 1; i++) { ll il = ceil (l - 1e-7) + (ceil (l + 1e-7) == mx_old), ir = floor (r + 1e-7); //cout << il << ' ' << ir << endl; if (il > ir) continue; MinMax(il, ir, &mn, &mx); //cout << ' ' << mn << ' ' << mx << endl; if (mn != -1) { gap = max (gap, mn - mx_old); mx_old = mx; } l += d, r += d; } ll il = ceil (l - 1e-7) + (ceil (l + 1e-7) == mx_old), ir = floor (r + 1e-7); //cout << il << ' ' << ir << endl; if (il <= ir) MinMax(il, ir, &mn, &mx); //cout << ' ' << mn << ' ' << mx << endl; if (mn != -1 && il <= ir) { gap = max (gap, mn - mx_old); mx_old = mx; } gap = max (gap, e - mx_old); return gap; }

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:44:5: warning: unused variable 's' [-Wunused-variable]
   44 |  ll s = mn, e = mx;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...