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

#TimeUsernameProblemLanguageResultExecution timeMemory
365269valerikkPacking Biscuits (IOI20_biscuits)C++17
100 / 100
96 ms1516 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll x; int k; ll sum[64]; ll a[64]; map<ll, ll> mp; ll f(ll n) { if (n < 0) return 0; if (n == 0) return 1; if (mp.count(n)) return mp[n]; mp[n] = 0; ll& ret = mp[n]; int i = 0; while ((1ll << (i + 1)) <= n) i++; ret += f((1ll << i) - 1); ll mx = min(n, sum[i] / x); ret += f(mx - (1ll << i)); return ret; } ll count_tastiness(ll xx, vector<ll> aa) { x = xx; k = 60; while ((int)aa.size() < k) aa.push_back(0); for (int i = 0; i < k; i++) a[i] = aa[i]; for (int i = 0; i < k; i++) { sum[i] = a[i] * (1ll << i); if (i != 0) sum[i] += sum[i - 1]; } mp.clear(); return f((1ll << k) - 1); } #ifdef LOCAL int main() { ios::sync_with_stdio(false); cin.tie(0); int kk; ll xx; cin >> kk >> xx; vector<ll> aa(kk); for (int i = 0; i < kk; i++) cin >> aa[i]; cout << count_tastiness(xx, aa) << endl; return 0; } #endif
#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...