(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 #535821

#TimeUsernameProblemLanguageResultExecution timeMemory
535821KoDPacking Biscuits (IOI20_biscuits)C++17
100 / 100
214 ms1356 KiB
#include <bits/stdc++.h> #include "biscuits.h" using ll = long long; using std::vector; using std::array; using std::pair; ll count_tastiness(ll x, vector<ll> a) { a.resize(60); array<ll, 60> max; ll sum = 0; for (int i = 0; i < 60; ++i) { sum += a[i] << i; max[i] = sum / x; } std::map<pair<int, ll>, ll> memo; auto dfs = [&](auto&& self, int d, ll y) -> ll { y = std::min(y, (1ll << (d + 1)) - 1); if (d == -1) { return 0; } if (const auto itr = memo.find(pair(d, y)); itr != memo.end()) { return itr->second; } const ll ub = std::min(max[d], y) - (1ll << d); if (ub >= 0) { ll ret = 1; for (int k = 0; k < d; ++k) { ret += self(self, k, ub); } return memo[{d, y}] = ret; } else { return memo[{d, y}] = 0; } }; ll ret = 1; for (int k = 0; k < 60; ++k) { ret += dfs(dfs, k, 1ll << 60); } return ret; }
#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...