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>
#include "biscuits.h"
using namespace std;
int k = 122;
vector<long long>a;
long long x;
map<long long, long long>dp[125];
long long solve(int i, long long j) {
if(i>=k) return 1;
if(dp[i].count(j)) return dp[i][j];
long long &ret = dp[i][j];
long long cr = a[i] + j;
ret = solve(i+1, cr/2);
if(cr>=x) ret += solve(i+1, (cr-x)/2);
return ret;
}
long long count_tastiness(long long X, vector<long long> A) {
A.resize(122);
a = A, x = X;
for(int i=0; i<k-1; ++i) {
if(a[i]<=x) continue;
long long take = max(0LL, a[i] - x);
a[i] -= take - (take & 1);
a[i+1] += take / 2;
}
for(int i=0; i<125; ++i) dp[i].clear();
return solve(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... |