#include <bits/stdc++.h>
#include "biscuits.h"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
#define ll long long
ll count_tastiness(ll x, vector<ll> a) {
ll ans = 0, sum = 0;
int n = a.size();
for (ll i = 0; i < n; i++) sum += (1LL << i) * a[i];
for (ll y = 0; y <= sum / x; y++) {
vector<ll> c = a;
ll mx = 0;
while ((1LL << (mx + 1)) <= y) mx++;
ll ptr = mx;
for (ll i = mx; i >= 0;) {
while (ptr >= 0 && !(y & (1 << ptr))) ptr--;
if (ptr < 0) break;
i = min(i, ptr);
ll diff = (ptr - i);
diff = (1LL << diff);
if (c[i] - x * diff >= 0) {
ptr--;
c[i] -= x * diff;
continue;
}
else {
if (i == 0) break;
c[i - 1] += 2 * c[i];
i--;
}
}
if (ptr < 0) ans++;
}
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... |