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;
const int k = 60;
ll x;
vector<ll> a;
vector<map<ll, ll>> dp;
ll calc(int i, ll cnt){
if(i == k) return 1;
if(dp[i].count(cnt)) return dp[i][cnt];
ll ans = 0;
if(cnt+a[i] >= x){
ans += calc(i+1, (cnt+a[i]-x)/2);
}
ans += calc(i+1, (cnt+a[i])/2);
return dp[i][cnt] = ans;
}
ll count_tastiness(ll x_, vector<ll> a_) {
x = x_; a = a_;
a.resize(k);
for(int i = 0; i < k; i++){
if(a[i] <= x+1) continue;
ll cnt = (a[i]-x)/2;
a[i] -= 2*cnt;
a[i+1] += cnt;
}
dp.clear();
dp.resize(k);
return calc(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... |