# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306320 | MrDomino | Packing Biscuits (IOI20_biscuits) | C++14 | 1093 ms | 384 KiB |
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;
typedef long long ll;
ll x;
vector<ll> a;
vector<ll> limit;
int n;
int sol;
const ll INF = (ll) 2e18;
ll mul(ll x, ll y)
{
if (x == 0 || y == 0)
{
return 0;
}
ll p = x * y;
if (p % x == 0 && p / x == y && p <= INF)
{
return p;
}
else
{
return INF;
}
}
void bkt(int i, ll sum)
{
if (i == 60)
{
sol++;
return;
}
if (sum <= limit[i])
{
bkt(i + 1, sum);
}
if (sum + mul(x, (1LL << i)) <= limit[i])
{
ll k = sum + x * (1LL << i);
bkt(i + 1, sum + x * (1LL << i));
}
}
ll count_tastiness(ll xx, vector<ll> aa)
{
sol = 0;
x = xx;
a = aa;
n = (int) a.size();
limit = a;
ll c = 0;
for (int i = 0; i < n; i++)
{
c += (1LL << i) * a[i];
limit[i] = c;
}
while ((int) limit.size() < 60)
{
limit.push_back(limit.back());
}
bkt(0, 0);
return sol;
}
Compilation message (stderr)
# | 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... |