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>
#pragma GCC optimize("O3")
#define endl '\n'
using namespace std;
unordered_map <long long, long long> dp[120];
long long x;
vector <long long> v;
int sz;
long long f(int pos, long long pr) {
long long sum = pr;
if (pos < sz)
sum += v[pos];
if (sum < x && pos >= sz)
return 1;
if (dp[pos].count(pr))
return dp[pos][pr];
long long ans = f(pos + 1, sum >> 1ll);
if (sum >= x)
ans += f(pos + 1, (sum - x) >> 1ll);
return dp[pos][pr] = ans;
}
long long count_tastiness(long long x1, vector <long long> a) {
x = x1;
v = a;
sz = (int)v.size();
for (int i = 0; i < 120; i++)
dp[i].clear();
return f(0, 0);
}
/*
cin >> a[i];
cout << count_tastiness(x, a) << endl;
}
*/
# | 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... |