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
int mp[61][20005];
int a[61], x;
int solve (int b, int k) {
if (b == 60)
return 1;
assert (k <= x * 2 + 4);
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++) {
for (int j = 0; j < 20005; j++)
mp[i][j] = 0;
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[i] >= x) {
int w = (a[i] - x) / 2;
a[i + 1] += w;
a[i] -= w * 2;
}
}
return solve (0, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |