(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #421511

#TimeUsernameProblemLanguageResultExecution timeMemory
421511KoDPacking Biscuits (IOI20_biscuits)C++17
100 / 100
136 ms1336 KiB
#include <bits/extc++.h> #include "biscuits.h" namespace { using ll = long long; template <class T> using Vec = std::vector<T>; template <class T, class U> using HashTable = __gnu_pbds::gp_hash_table<T, U>; template <class F> struct RecLambda: private F { explicit RecLambda(F&& f): F(std::forward<F>(f)) {} template <class... Args> decltype(auto) operator() (Args&&... args) const { return F::operator()(*this, std::forward<Args>(args)...); } }; } ll count_tastiness(ll x, Vec<ll> a) { a.resize(60); std::array<ll, 60> sum{}; for (int i = 0; i < 60; ++i) { sum[i] = (i == 0 ? 0 : sum[i - 1]) + (a[i] << i); } HashTable<ll, ll> table; table[1] = 1; return RecLambda([&](auto&& dfs, const ll n) -> ll { if (n <= 0) { return 0; } if (table[n] != 0) { return table[n]; } int logn = 0; while (((ll) 1 << (logn + 1)) < n) { logn += 1; } return table[n] = dfs((ll) 1 << logn) + dfs(std::min(sum[logn] / x + 1, n) - ((ll) 1 << logn)); })((ll) 1 << 60); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...