이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |