# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032264 | mdn2002 | 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.
/*
Mayoeba Yabureru
*/
#include<bits/stdc++.h>
using namespace std;
long long count_tastiness(long long x, vector<long long> a) {
while (a.size() != 200) a.push_back(0);
map<long long, long long> dp[202];
function<long long(int, long long)> f = [&] (int i, long long sum) {
if (i > 60 && sum == 0) return 1ll;
if (dp[i].count(sum)) return dp[i][sum];
long long ans = f(i + 1, (sum + a[i]) / 2);
if (sum + a[i] >= x) ans += f(i + 1, (sum + a[i] - x) / 2);
return dp[i][sum] = ans;
};
return f(0, 0);
}
int main() {
int q;
assert(scanf("%d", &q) == 1);
vector<int> k(q);
vector<long long> x(q);
vector<vector<long long>> a(q);
vector<long long> results(q);
for (int t = 0; t < q; t++) {
assert(scanf("%d%lld", &k[t], &x[t]) == 2);
a[t] = vector<long long>(k[t]);
for (int i = 0; i < k[t]; i++) {
assert(scanf("%lld", &a[t][i]) == 1);
}
}
fclose(stdin);
for (int t = 0; t < q; t++) {
results[t] = count_tastiness(x[t], a[t]);
}
for (int t = 0; t < q; t++) {
printf("%lld\n", results[t]);
}
fclose(stdout);
return 0;
}