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 "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
ll X;
ll A[200200];
long long count_tastiness(long long _X, std::vector<long long> a)
{
X = _X;
vector<ll> S(sz(a) + 1, 0);
ll base = 1;
for (int i = 0; i < sz(a); ++i)
{
S[i] += a[i] * base;
S[i + 1] += S[i];
base *= 2;
}
ll ans = 1;
A[0] = 0;
base = 1;
for (int i = 0; base * X <= S.back(); ++i)
{
ll size = ans;
ll bound = (i < sz(S)) ? S[i] : S.back();
for (int j = 0; j < size; ++j)
{
ll y = A[j];
if ((y + base) * X <= bound)
A[ans++] = y + base;
else
break;
}
base *= 2;
}
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... |