Submission #306111

#TimeUsernameProblemLanguageResultExecution timeMemory
306111MrDominoPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1091 ms384 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool check(ll y, ll x, vector<ll> a)
{
    /// can I form the number y x times???
    int n = (int) a.size();
    if (log2(y) >= n)
    {
        return 0;
    }
    ll have = 0;
    ll need = 0;
    for (int i = 0; i < n; i++)
    {
        have += a[i] * (1LL << i);
        if (y & (1LL << i))
        {
            need += x * (1LL << i);
        }
        if (have < need)
        {
            return 0;
        }
    }
    return 1;
}

ll count_tastiness(ll x, vector<ll> a)
{
    ll sol = 0;
    for (ll y = 0; y <= (ll) 5e5; y++)
    {
        sol += check(y, x, a);
    }
    return sol;
}


#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...