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;
using ll = long long;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL<<(i))
namespace trung{
ll dp[61];
ll req[61];
ll sum[61];
ll a[61];
}
long long count_tastiness(long long x, std::vector<long long> A) {
using namespace trung;
for (ll i = 0;i < 60;i ++){
dp[i] = 0;
req[i] = 0;
}
for (ll i = 0;i < sz(A);i ++)a[i] = A[i];
for (ll i = 0;i < 60;i ++){
sum[i] = a[i] * MASK(i);
if (i)sum[i] += sum[i-1];
req[i] = (sum[i]/x)-MASK(i);
}
for (ll i = 0; i < 60;i ++){
ll cur = MASK(i+1)-1;
for (ll j = i;j >= 0;j --){
if (BIT(cur,j)){
if (j==0)dp[i]++;
else dp[i]+=dp[j-1];
cur -= MASK(j);
cur = min(cur,req[j]);
if (cur < 0){
break;
}
}
if (j==0)dp[i]++;
}
}
return dp[59];
}
# | 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... |