#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
long long count_tastiness(long long x, vector<long long> a){
while (a.size()<=60)a.push_back(0);
vector<int> psum(65, a[0]), dp(65, 0);
for (int i=1; i<=60; ++i)psum[i]=psum[i-1]/2+a[i];
dp[0]=1+(a[0]>=x);
for (int i=1; i<=60; ++i){
dp[i]=dp[i-1];
if (psum[i]<x)continue;
int c=max(0ll, x-a[i]);
for (int j=i-1; j>=1; --j){
c*=2;
if (psum[j]>=c+x)dp[i]+=dp[j-1], c=max(0ll, c+x-a[j]);
else c=max(0ll, c-a[j]);
}
dp[i]+=(a[0]>=c*2+x?2:1);
}
return dp[60];
}
# | 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... |