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>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
using namespace std;
long long X;
vector<long long> A;
int k;
// long long dp[61][200020];
map<int, map<long long, int>> dp;
long long cnt=0;
long long solve(int i, long long add) {
if(i == k)return 1;
if(dp[i].find(add)!=dp[i].end())return dp[i][add];
dp[i][add]=0;
cnt++;
if(add+A[i] >= X) {
dp[i][add] += solve(i+1, (add+A[i]-X)/2);
}
dp[i][add] += solve(i+1, (add+A[i])/2);
return dp[i][add];
}
long long count_tastiness(long long x, std::vector<long long> a) {
dp.clear();
X=x;
A=a;
k = 60;
A.resize(61);
// memset(dp, -1, sizeof dp);
for(int i = 0;i<k;i++) {
if(A[i] > x) {
long long c = A[i]-x;
A[i+1] += c/2;
c/=2;
c*=2;
A[i] -= c;
}
}
long long res = solve(0, 0);
return res;
}
# | 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... |