Submission #934048

#TimeUsernameProblemLanguageResultExecution timeMemory
934048EJIC_B_KEDAXPacking Biscuits (IOI20_biscuits)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> using ll = long long; using namespace std; mt19937 mt(time(nullptr)); vector<ll> tmp, origin, dp; ll calc(ll x, int pos) { ll sum = (1ll << pos) * tmp[pos]; int ptr = pos; while (ptr > 0 && sum < (1ll << pos) * x) { ptr--; sum += (1ll << ptr) * tmp[ptr]; } if (sum < (1ll << pos) * x) { return 1; } if (ptr == pos) { if (ptr == 0) { return 2; } else { return 2 * dp[ptr - 1]; } } tmp[ptr] = (sum - (1ll << pos) * x) / (1ll << ptr); ll res = calc(x, ptr); tmp[ptr] = origin[ptr]; return res + (ptr ? dp[ptr - 1] : 0); } ll count_tastiness(ll x, vector<ll> a) { while (a.size() < 60) { a.push_back(0); } int n = 60; for (int i = 0; i < n; i++) { if (a[i] > x + 1) { a[i + 1] += (a[i] - x) / 2; a[i] -= (a[i] - x) / 2; } } origin = a; tmp.resize(n); tmp = a; dp.resize(n, 0); ll res = 0; for (int i = 0; i < n; i++) { dp[i] = calc(x, i); res += dp[i] - 1; } return res + 1; }
#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...