Submission #769736

#TimeUsernameProblemLanguageResultExecution timeMemory
769736boris_mihovPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1076 ms340 KiB
#include "biscuits.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 64;
const int INF = 1e9;

int n;
llong x;
llong a[MAXN];

llong rec(int pos, llong prenos)
{
    if (pos >= n && prenos == 0)
    {
        return 1;
    }

    llong ans = 0;
    llong curr = a[pos] + prenos;
    if (curr >= x) ans += rec(pos + 1, (curr - x) / 2);
    ans += rec(pos + 1, curr / 2);
    return ans;
}

llong count_tastiness(llong X, std::vector <llong> A)
{
    n = A.size();
    x = X;

    llong sum = 0;
    for (int i = 0 ; i < n ; ++i)
    {
        a[i] = A[i];
        sum += a[i] * (1LL << a[i]);
    }

	return rec(0, 0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...