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;
long long x, k;
vector<long long> a, pre;
long long count_tastiness(long long X, vector<long long> A)
{
x = X, a = A, k = A.size();
long long res = 0;
for (long long y = 0; y <= 100000; y++)
{
a = A;
pre = a;
for (long long j = 1; j < k; j++)
{
pre[j] = (pre[j] << j) + pre[j - 1];
}
// if (y * x > pre[k - 1]) continue;
long long f = 1;
for (long long i = 60; i >= 0; i--)
{
if (!(y >> i & 1)) continue;
vector<long long> pre = a;
for (long long j = 1; j < k; j++)
{
pre[j] = (pre[j] << j) + pre[j - 1];
}
long long need = X;
for (long long j = i; j >= 0; j--)
{
// if (need > pre[min(k - 1, j)]) break;
if (j <= k - 1)
{
long long mn = min(need, a[j]);
need -= mn, a[j] -= mn;
}
need <<= 1;
}
if (need)
{
f = 0;
break;
}
}
res += f;
}
return res;
}
# | 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... |