This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef ARTHUR_LOCAL
#include "biscuits.h"
#endif
#ifdef ARTHUR_LOCAL
#include <bits/stdc++.h>
#endif
using namespace std;
using ll = long long;
#define len(x) int((x).size())
ll dp[81][20001];
ll count_tastiness(ll x, vector<ll> A)
{
while(len(A) <= 80) A.push_back(0LL);
for(int i=0; i<len(A); i++)
{
if(A[i] >= x)
{
A[i+1] += ll((A[i]-x)/2LL);
A[i] = x;
}
}
dp[0][1] = 1;
for(int b=0; b<=79; b++)
{
// transition up from dp[b] using 1<<b
// case 1: don't add the zero
for(int i=0; i<=20000; i++)
{
dp[b+1][int(i/2) + A[b]] += dp[b][i];
}
for(int i=0; i<=20000; i++)
{
if(A[b] + int(i/2) >= x)
{
dp[b+1][int(i/2) + A[b] - x] += dp[b][i];
}
}
}
ll ans=0LL;
for(int i=0; i<=20000; i++)
{
ans += dp[80][i];
}
return ans;
}
#ifdef ARTHUR_LOCAL
int main()
{
cout << count_tastiness(3, {5, 2, 1}) << endl;
}
#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... |