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;
#include "biscuits.h"
#define int long long
int S[61]; int X;
unordered_map<int,int> memo;
int dp(int n){
if (n<=0) return 0;
if (memo.count(n)) return memo[n];
int l2=0; int t=1; while (2*t < n) l2++, t*=2;
return memo[n] = dp(t) + dp(min(1+ S[l2]/X, n) - t);
}
long long count_tastiness(long long x, std::vector<long long> a) {
memo.clear(); X = x; a.resize(61);
S[0] = a[0];
for (int i=1; i<61; i++) S[i] = S[i-1] + a[i] * (1ll<<i);
memo[1] = 1;
return dp((int)1e18+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... |