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 <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define ad push_back
#define lli long long
lli dp[123][20010];
long long count_tastiness(long long x, std::vector<long long> a)
{
for (int i = 0; i <= 60; i++) a.ad(0);
for (int i = 0; i < (int)a.size(); i++)
for (int j = 0; j <= 2*x; j++) dp[i][j]=0;
for (int i = 0; i < (int)a.size() - 1; i++)
{
a[i+1] += max(0LL, (a[i]-x)/2LL);
a[i] = min(a[i], x);
}
//for(auto p : a) cout << p << " "; cout << endl;
dp[0][a[0]]=1;
if(a[0]==x) dp[0][0]=1;
for (int i = 1; i < (int)a.size(); i++)
{
for (int j = 0; j <= 2*x; j++)
{
if(dp[i-1][j]==0) continue;
int sm = j/2;
dp[i][sm+a[i]] += dp[i-1][j];
if(sm + a[i] >= x) dp[i][sm+a[i]-x] += dp[i-1][j];
}
}
lli ret = 0;
for (int i = 0; i <= 2*x; i++)
ret += dp[(int)a.size()-1][i];
return ret;
}
# | 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... |