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

#TimeUsernameProblemLanguageResultExecution timeMemory
355593dooweyPacking Biscuits (IOI20_biscuits)C++14
100 / 100
102 ms1388 KiB
#include <bits/stdc++.h> #include "biscuits.h" using namespace std; typedef long long ll; vector<ll> a; map<ll,ll> dp; ll x; ll solve(ll n){ // how many <= n if(n < 0) return 0; if(n == 0) return 1; if(dp.count(n)) return dp[n]; ll lg = 0; while((1ll<<(lg+1)) <= n) lg ++ ; ll sol = solve((1ll<<lg)-1); // last bit not included ll sum = 0; for(int i = 0 ; i <= lg; i ++ ){ sum += (1ll << i) * 1ll * a[i]; } sol += solve(min(sum/x,n)-(1ll<<lg)); dp[n]=sol; return dp[n]; } ll count_tastiness(ll _x, vector<ll> _a) { a = _a; x = _x; dp.clear(); while(a.size() < 64) a.push_back(0); return solve((1ll<<61)); }
#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...