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>
using namespace std;
typedef long long ll;
#define sep ' '
const int MAXN = 62;
ll x , A[MAXN];
map<ll , ll> dp[MAXN];
ll solve(int i , ll j){
if(i == -1) return (j == 0);
if(j >= 4 * x) return 0;
if(dp[i].find(j) != dp[i].end()) return dp[i][j];
j = max(0ll , j - A[i]) * 2;
dp[i][j] = solve(i - 1 , j) + solve(i - 1 , j + x);
//cout << i << sep << j << sep << dp[i][j] << endl;
return dp[i][j];
}
ll count_tastiness(ll x, vector<ll> a) {
::x = x; int n = a.size();
for(int i = 0 ; i < n ; i++){
A[i] = a[i];
}
for(int i = 0 ; i < MAXN ; i++){
dp[i] = map<ll , ll>();
}
for(int i = 0 ; i + 1 < MAXN ; i++){
ll val = min(A[i] , A[i] % x + x);
A[i + 1] += (A[i] - val) / 2;
A[i] = val;
}
return solve(61 , 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... |