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 <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "biscuits.h"
bool bit(ll m, int i) {
return (m >> i) & 1;
}
ll count_tastiness(ll x, vector<ll> a) {
a.resize(200, 0);
for (int i = 0; i < 150; ++i) {
ll carry = max(0LL, (a[i] - x) / 2);
a[i + 1] += carry;
a[i] -= 2 * carry;
}
assert(*max_element(all(a)) <= x + 1);
reverse(all(a));
vector<ll> dp(x + 1, 0);
dp[0] = 1, dp[x] = 1;
for (ll h : a) {
// cout << "h = " << h << endl;
vector<ll> np(x + 1, 0);
for (ll k = 0; k <= x; ++k) {
// place 0
if (2 * k - h <= x) {
np[max(0LL, 2 * k - h)] += dp[k];
}
// place 1
if (2 * k - h <= 0) {
np[max(0LL, 2 * k - h + x)] += dp[k];
}
}
dp = np;
// for (ll e : dp) {
// cout << e << " ";
// }
// cout << endl;
}
return dp[0];
}
#ifdef LC
#include "grader.cpp"
#endif
# | 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... |