# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425665 | idk321 | Packing Biscuits (IOI20_biscuits) | C++17 | 1165 ms | 1758468 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 "biscuits.h"
#include <bits/stdc++.h>;
using namespace std;
typedef long long ll;
long long count_tastiness(long long x, std::vector<long long> a) {
ll sum = 0;
int k = 60;
for (int i = 0; i < a.size(); i++)
{
sum += (1LL << i) * a[i];
}
if (sum <= 100000)
{
int res = 0;
for (int i = 0; i <= sum; i++)
{
bool poss = true;
vector<ll> cur(60);
for (int j = 0; j < a.size(); j++) cur[j] = a[j];
for (int j = 0; j < k; j++)
{
if ((1LL << j) & i)
{
cur[j] -= x;
if (cur[j] < 0)
{
poss = false;
break;
}
}
if (j + 1 < k)
{
cur[j + 1] += cur[j] / 2;
}
}
if (poss) res++;
}
return res;
}
a.resize(k);
for (int i = 0; i < k - 1; i++)
{
if (a[i] - (x + 2) >= 0)
{
ll diff = (a[i] - (x + 2));
a[i + 1] += diff / 2;
a[i] -= (diff / 2) * 2;
}
}
vector<vector<ll>> dp(k + 1, vector<ll>(x * 100));
dp[k][0] = 1;
for (int i = k - 1;i >= 0; i--)
{
for (int j = 0; (j + a[i]) / 2 < x * 100 && j < x * 100; j++)
{
if (j + a[i] < x)
{
dp[i][j] = dp[i + 1][(j + a[i]) / 2];
} else
{
dp[i][j] = dp[i + 1][(j + a[i]) / 2] + dp[i + 1][(j + a[i] - x) / 2];
}
}
}
return dp[0][0];
}
/*
1
15 1
1 2 0 2 1 0 0 2 2 1 1 2 0 0 1
*/
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... |