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;
int K;
long long X;
vector<long long>v;
vector<map<long long, long long>>mp;
long long dp(int i, long long cnt) {
if(i == K /*or ((1LL << K) / (1LL << i)) < X*/)
return 1;
if(mp[i].count(cnt))
return mp[i][cnt];
long long ret = 0;
if(cnt + v[i] >= X)
ret = dp(i+1, (cnt + v[i] - X)/2);
ret += dp(i+1, (cnt+v[i])/2);
return mp[i][cnt] = ret;
}
long long count_tastiness(long long x, vector<long long>a) {
X = x;
v = a;
K = a.size();
mp.clear();
mp.resize(K);
return dp(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... |