# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789439 | borisAngelov | Packing Biscuits (IOI20_biscuits) | C++17 | 1084 ms | 340 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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
long long count_tastiness(long long x, vector<long long> a)
{
int sum = 0;
for (int i = 0; i < a.size(); ++i)
{
sum += a[i] * (1LL << i);
}
int bits = 60;
int up_to = sum / x;
int ans = 0;
for (int i = 0; i <= up_to; ++i)
{
vector<int> cnt(20, 0);
for (int j = 0; j <= 16; ++j)
{
if (j < a.size())
{
cnt[j] = a[j];
}
else
{
cnt[j] = 0;
}
}
bool is_answer = true;
for (int times = 1; times <= x; ++times)
{
for (int bit = 16; bit >= 0; --bit)
{
if ((i & (1 << bit)) == 0)
{
continue;
}
int need = 1;
bool found = false;
for (int j = bit; j >= 0; --j)
{
if (cnt[j] >= need)
{
found = true;
cnt[j] -= need;
break;
}
need = 2 * need;
}
if (found == false)
{
is_answer = false;
break;
}
}
if (is_answer == false)
{
break;
}
}
if (is_answer == true)
{
++ans;
}
}
return ans;
}
/*
1
3 3
5 2 1
1
3 2
2 1 2
*/
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... |