This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
using namespace std;
#include <bits/stdc++.h>
#include "biscuits.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
ll count_tastiness(ll x, vector<ll> a) {
int k = a.size() * 4;
rep(i,0,k) a.pb(0);
rep(i,0,k-1) {
if (a[i] <= x) continue;
a[i + 1] += (a[i] - x) / 2;
a[i] = x;
}
assert(a[k-1] == 0);
vector<vector<ll>> dp(k, vector<ll>(2*x, 0));
dp[0][a[0]] = 1;
if (a[0] == x) dp[0][0] = 1;
rep(i,0,k-1) rep(j,0,2*x) {
dp[i+1][a[i+1] + j/2] += dp[i][j];
if (a[i+1] + j/2 >= x) dp[i+1][a[i+1] + j/2 - x] += dp[i][j];
}
ll ans = 0;
rep(j,0,2*x) ans += dp[k-1][j];
return ans;
}
# | 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... |