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;
vector<ll>a;
ll x,n,dp[65],f[65];
ll best(ll d)
{
if(d==-1)
return 1;
ll &r=dp[d];
if(r!=-1)
return r;
r=best(d-1);
ll c=0;
for(ll i=d; i>=0; i--)
{
c+=a[i]/f[d-i];
if(c>=x)
{
return r+=best(i-1);
}
}
return r;
}
long long count_tastiness(ll X, vector<ll> A)
{
x=X,a=A,n=61;
if(f[0]==0)
{
f[0]=1;
for(ll i=1;i<=60;i++)
f[i]=f[i-1]*2;
}
a.resize(n);
for(ll i=0; i<n; i++)
{
if(a[i]<x)
continue;
ll op=(a[i]-x)/2;
a[i]-=op;
if(i<n-1)
a[i+1]+=op;
}
memset(dp,-1,sizeof dp);
return best(n-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... |