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

#TimeUsernameProblemLanguageResultExecution timeMemory
569814StickfishPacking Biscuits (IOI20_biscuits)C++17
100 / 100
78 ms1236 KiB
#include "biscuits.h" #include <map> #include <cassert> #include <algorithm> using namespace std; using ll = long long; const ll INF = 1e18 + 177013; const int MAXK = 61; ll sm[MAXK]; map<ll, ll> mp; ll get_ans(ll mxsm) { if (mxsm == 0) return 1; int i = 0; int cnt = 0; while (true) { i = 0; while (1ll << (i + 1) <= mxsm) ++i; if (mxsm <= sm[i]) { break; } else { mxsm = sm[i]; } assert(++cnt <= 100); } if (mxsm == 0) return 1; if (mp.find(mxsm) != mp.end()) return mp[mxsm]; ll t = get_ans((1ll << i) - 1) + get_ans(mxsm - (1ll << i)); mp[mxsm] = t; return t; } ll count_tastiness(ll x, vector<ll> a) { mp.clear(); int k = a.size(); for (int i = 0; i < MAXK; ++i) sm[i] = 0; for (int i = 0; i < k; ++i) sm[i] = a[i] << i; for (int i = 1; i < MAXK; ++i) { sm[i] += sm[i - 1]; } for (int i = 0; i < MAXK; ++i) { sm[i] /= x; } return get_ans(INF); }
#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...