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;
int n,m;
long long sum[70];
map<long long,long long>dp[70];//第i层,上限为j
long long dfs(int dep,long long lim){
lim=min(lim,min(sum[dep],(2ll<<dep)-1));
if(dp[dep].count(lim)) return dp[dep][lim];
long long _1=1ll<<dep,res=0;
if(_1<=lim){
if(dep) res+=dfs(dep-1,lim-_1);
else res++;
}
if(dep) res+=dfs(dep-1,lim);
else res++;
return dp[dep][lim]=res;
}
long long count_tastiness(long long x,vector<long long> a){
for(int i=0;i<=60;i++) sum[i]=((int)a.size()>i?a[i]<<i:0)+sum[i-1];
for(int i=0;i<=60;i++) dp[i].clear(),sum[i]/=x;
return dfs(60,1ll<<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... |