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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int K = 60;
ll count_tastiness(ll X, vector<ll> A){
while(A.size() < K+1) A.pb(0);
A.pb(0);
vector<ll> S(K+1);
for(int i = 0; i < K; i++){
if(i) S[i]+=S[i-1];
S[i]+=A[i]*(1LL<<i);
}
unordered_map<ll, ll> dp;
dp[0] = 1;
function<ll(ll)> DP = [&](ll x){
if(x < 0) return 0LL;
if(dp.find(x) != dp.end()) return dp[x];
int i = 63-__builtin_clzll(x);
dp[x] = DP((1LL<<i)-1)+DP(min(x, S[i]/X)-(1LL<<i));
return dp[x];
};
return DP(1LL<<K);
}
# | 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... |