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 <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "biscuits.h"
bool bit(ll m, int i) {
return (m >> i) & 1;
}
ll count_tastiness(ll x, vector<ll> a) {
auto check = [&](ll y) {
vector<ll> b = a;
b.resize(61, 0);
for (int k = 60; k >= 0; --k) {
if (!bit(y, k)) {
continue;
}
for (ll it = x; it--; ) {
ll need = 1;
for (int pos = k; pos >= 0 && need; --pos) {
ll delta = min(need, b[pos]);
b[pos] -= delta;
need -= delta;
need *= 2;
}
if (need) {
return false;
}
}
}
return true;
};
ll sum = 0;
for (int i = 0; i < (int)a.size(); ++i) {
sum += a[i] << i;
}
ll answer = 0;
for (ll y = 0; x * y <= sum; ++y) {
if (check(y)) {
++answer;
}
}
return answer;
}
#ifdef LC
#include "grader.cpp"
#endif
# | 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... |