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>
const int MAX = 1e5;
long long count_tastiness(long long x, std::vector<long long> a) {
if (x > MAX) return 1;
int n = std::min(19, (int)a.size());
long long ans = 1, sm = 0;
for (int i = 0; i < n; ++i) sm += a[i] * (1 << i);
auto works = [&](int count) -> bool {
std::vector<long long> cur = a;
for (int i = n - 1; i >= 0; --i) {
if (count & (1 << i)) {
long long tmp = x;
int j = i, need = 1;
while (tmp) {
if (cur[j] < need) {
j--;
if (j < 0) return false;
need <<= 1;
} else {
--tmp;
cur[j] -= need;
}
}
} else continue;
}
return true;
};
for (int count = 1; count * x <= sm; ++count) {
ans += works(count);
}
return ans;
}
# | 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... |