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>
using namespace std;
const int LIMIT = 25;
long long count_tastiness(long long x, std::vector<long long> a) {
map<pair<int,int>,long long> memo;
function<long long(long long,long long)> calc = [&](long long i,long long j){
j=max(j,0ll);
if(i==-1)return j==0 ? 1ll : 0ll;
if(j>(((long long)1e18)/(1ll<<i)))return 0ll;
if(memo.count({i,j}))return memo[{i,j}];
long long ac = calc(i-1,2ll*(j-a[i]));
if(ac>0)return memo[{i,j}] = calc(i-1,2ll*(j-a[i]+x))+ac;
else return memo[{i,j}]=0ll;
};
a.resize(LIMIT+1);
return calc(LIMIT,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... |