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;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
long long count_tastiness(long long x, vector<long long> a) {
    map<vector<long long>, long long> memo;
    function<long long(vector<long long>)> Solve = [&](vector<long long> b) {
        if (b.size() == 1) {
            return b[0] / x + 1;
        } else if (memo.count(b)) {
            return memo[b];
        }
        debug(b);
        long long res = 0;
        for (long long t : {0LL, x}) {
            if (b[0] < t) {
                continue;
            }
            auto c = b;
            c[1] += (c[0] - t) / 2;
            c.erase(c.begin());
            res += Solve(c);
        }
        return memo[b] = res;
    };
    return Solve(a);
}
#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    debug(count_tastiness(3, {5, 2, 1}));  // 5
    debug(count_tastiness(2, {2, 1, 2}));  // 6
    return 0;
}
#endif
| # | 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... |