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

#TimeUsernameProblemLanguageResultExecution timeMemory
579747SlavicGPacking Biscuits (IOI20_biscuits)C++17
100 / 100
90 ms1336 KiB
#include "biscuits.h" #include "bits/stdc++.h" #define ll long long std::map<ll, ll> dp; const int K = 62; ll s[K]; ll rec(ll n, ll x) { if(n <= 0) return 0; if(n == 1) return 1; if(dp.count(n)) return dp[n]; ll largestSmaller = 0; for(ll i = 0; i < K; ++i) { if((1LL << i) < n) largestSmaller = i; } ll ans = rec((1LL << largestSmaller), x) + rec(std::min(n, 1 + s[largestSmaller] / x) - (1LL << largestSmaller), x); dp[n] = ans; return ans; } long long count_tastiness(long long x, std::vector<long long> a) { dp.clear(); for(ll i = 0; i < K; ++i) s[i] = 0; for(ll i = 0; i < (ll)a.size(); ++i) { s[i] = a[i] * (1LL << i); if(i) s[i] += s[i - 1]; } for(ll i = (ll)a.size(); i < K; ++i) s[i] = s[i - 1]; if(s[(ll)a.size() - 1] < x) return 1; return rec((s[(ll)a.size() - 1]) / x + 1, x); }
#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...