# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042703 | DorostWef | Packing Biscuits (IOI20_biscuits) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
#define int long long
map <int, int> mp[61];
int a[61], x;
int solve (int b, int k) {
if (b == 60)
return 1;
if (mp[b][k])
return mp[b][k];
int ans = solve (b + 1, ((a[b] + k) / 2));
if ((a[b] + k) >= x) {
ans += solve (b + 1, ((a[b] + k - x) / 2));
}
return mp[b][k] = ans;
}
long long count_tastiness(long long xx, std::vector<long long> aa) {
for (int i = 0; i < 61; i++) {
mp[i].clear();
a[i] = 0;
}
x = xx;
for (int i = 0; i < (int)aa.size(); i++)
a[i] = aa[i];
for (int i = 0; i < 61; i++) {
if (a[b] >= x) {
int w = (a[b] - x) / 2;
a[b + 1] += w;
a[b] -= w * 2;
}
}
return solve (0, 0);
}