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;
long long s[60], x;
unordered_map<long long, long long> memo;
long long dp(long long n) {
if(n == 1) return 1;
if(n <= 0) return 0;
if(memo.count(n)) return memo[n];
int bt = 63-__builtin_clzll(n-1);
long long pw = 1LL<<bt;
return memo[n] = dp(pw) + dp(min(n, 1+s[bt]/x)-pw);
}
long long count_tastiness(long long X, vector<long long> a) {
x = X;
int k = (int)a.size();
s[0] = a[0];
for(int i = 1; i < k; i++) s[i] = s[i-1] + a[i]*(1LL<<i);
memo.clear();
return dp(s[k-1]+1);
}
# | 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... |