Submission #56152

#TimeUsernameProblemLanguageResultExecution timeMemory
56152aquablitz11Rice Hub (IOI11_ricehub)C++14
100 / 100
29 ms13872 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; using ll = long long; const int N = 100010; ll qsl[N], qsr[N]; int besthub(int n, int L, int pos[], ll budget) { for (int i = 1; i <= n; ++i) { qsl[i] += qsl[i-1] + pos[i-1]; qsr[i] = qsr[i-1] + (L - pos[i-1]); } auto check = [&] (int cnt) { for (int l = 1, r = cnt; r <= n; ++l, ++r) { int m = (l+r)/2; ll d = qsr[m]-qsr[l-1] - (L-pos[m-1])*1ll*(m-l+1); d += qsl[r]-qsl[m] - (pos[m-1])*1ll*(r-m); if (d <= budget) return true; } return false; }; int b = 0; int e = n; while (b < e) { int m = (b+e+1)/2; if (check(m)) b = m; else e = m-1; } return b; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...