Submission #419630

#TimeUsernameProblemLanguageResultExecution timeMemory
419630KoDPacking Biscuits (IOI20_biscuits)C++17
42 / 100
1089 ms141172 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) { std::array<HashTable<ll, ll>, 60> table{}; a.resize(60); return RecLambda([&](auto&& dfs, const int k, const ll s) -> ll { if (k == 60) return 0; if (table[k].find(s) != table[k].end()) { return table[k][s]; } const auto t = s + a[k]; ll ret = dfs(k + 1, t / 2); if (t >= x) { ret += dfs(k + 1, (t - x) / 2); ret += 1; } return table[k][s] = ret; })(0, 0) + 1; }
#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...