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;
using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;
#define ST first
#define ND second
#define PB push_back
map<pair<int, ll>, ll>dp;
vector<ll>A;
ll X;
ll rec(int a, ll add) {
if(dp.find({a,add}) != dp.end()) return dp[{a,add}];
ll cur = A[a] + add;
if(a >= 65) return 1;
ll ans = 0;
if(cur >= X) {
cur -= X;
if(dp.find({a + 1, cur/2}) != dp.end()) ans+=dp[{a+1,cur/2}];
else ans += rec(a + 1, cur / 2);
cur += X;
}
if(dp.find({a+1,cur/2}) != dp.end()) ans += dp[{a+1, cur/2}];
else ans += rec(a + 1, cur/2);
return ans;
}
ll count_tastiness(ll x, vector<ll>a) {
A.resize(65);
for(int i = 0; i < (int)a.size(); ++i) A[i] = a[i];
X = x;
dp.clear();
return rec(0, 0);
}
//int main() {
// cout << count_tastiness(2,{2,1,2});
//}
# | 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... |