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;
#define f(i,a,b) for(int i = a;i < b;i++)
#define ll long long
#define ii pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define iii pair<ll,ii>
#include "biscuits.h"
ll dp[1<<20][65];
ll a[65] = {0};
ll x;
ll solve(ll extra,ll j,ll mask){
if(j > 60){
return 1;
}
if(dp[mask][j] != -1){
return dp[mask][j];
}
extra += a[j];
ll neo = mask>>1;
ll ans = solve(extra / 2,j+1,neo);
if(extra >= x){
ans += solve((extra - x) / 2,j+1,neo + (1<<19));
}
return dp[mask][j] = ans;
}
long long count_tastiness(long long X, vector<long long> A){
x = X;
ll k = A.size();
memset(dp,-1,sizeof dp);
f(i,0,65){
a[i] = 0;
}
f(i,0,k){
a[i] = A[i];
}
f(i,0,60){
if(a[i] > x){
ll posa = a[i] - x;
if(posa % 2 == 1){
a[i] = x+1;
posa--;
}
else{
a[i] = x;
}
a[i+1] += posa / 2;
}
}
return solve(0,0,0);
}
# | 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... |