#include "biscuits.h"
using i64 = long long;
constexpr int max_sum = 1E5;
long long count_tastiness(long long x, std::vector<long long> a) {
int k = a.size();
if (x > max_sum) {
return 1;
}
auto check = [&](int y) {
std::vector<i64> org_a = a;
int rep = x;
while (rep--) {
int want = y;
for (int i = k - 1; i >= 0; i--) {
int t = std::min(want / (1LL << i), a[i]);
a[i] -= t;
want -= t * (1LL << i);
}
if (want > 0) {
a = org_a;
return 0;
}
}
a = org_a;
return 1;
};
int ans = 0;
for (int y = 1; y * x <= max_sum; y++) {
ans += check(y);
}
return ans + 1;
}
# | 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... |