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;
long long n = a.size();
long long ans = 1, sm = 0;
for (long long i = 0; i < n; ++i) sm += a[i] * (1ll << i);
auto works = [&](long long count) -> bool {
std::vector<long long> cur = a;
for (long long i = n - 1; i >= 0; --i) {
if (count & (1ll << i)) {
long long tmp = x;
long long 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 (long long 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... |