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 <iostream>
#include <cstdio>
using namespace std;
// <|°_°|>
// M. Broccoli
const int NB_BITS = 60;
long long DP[NB_BITS + 1];
long long Sum[NB_BITS];
long long count_tastiness(long long nbPacks, vector <long long> Biscuits) {
for (int i = 0; i <= NB_BITS; i ++)
{
DP[i] = 1;
}
int sz = Biscuits.size();
Sum[0] = Biscuits[0];
for (int i = 1; i < sz; i ++)
{
Sum[i] = (Biscuits[i] << i) + Sum[i - 1];
}
for (int i = sz; i <= NB_BITS; i ++)
{
Sum[i] = Sum[i - 1];
}
for (int i = 1; i <= NB_BITS; i ++)
{
long long sum = 1LL << 60;
for (int j = i - 1; j >= 0; j --)
{
sum = min(sum, Sum[j]);
if (nbPacks <= (sum >> j))
DP[i] += DP[j], sum -= (nbPacks << j);
}
}
return DP[NB_BITS];
}
# | 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... |