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"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
ll X;
long long count_tastiness(long long _X, std::vector<long long> a)
{
vi b;
X = _X;
for (int i = 0; i < sz(a); ++i)
{
b.push_back(a[i]);
if (b[i] >= X)
{
ll remove = ((a[i] - X) / 2) * 2;
b[i] -= remove;
if (i + 1 >= sz(a))
a.push_back(0);
a[i + 1] += remove / 2;
}
}
if (b.back() != 0)
b.push_back(0);
vvi dp(sz(b), vi(X + 2, 0));
// b.back() == 0
for (int j = 0; j < sz(dp.back()); ++j)
dp.back()[j] = 1;
dp.back()[X] = 2;
dp.back()[X + 1] = 2;
for (int i = sz(b) - 2; i >= 0; --i)
{
for (int j = 0; j < sz(dp[i]); ++j)
{
ll vorrat = b[i] + j;
dp[i][j] += dp[i + 1][vorrat / 2]; // mache nichts
if (vorrat >= X)
dp[i][j] += dp[i + 1][(vorrat - X) / 2]; // set a bit
}
}
return dp[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... |