Submission #921474

#TimeUsernameProblemLanguageResultExecution timeMemory
921474ksujay2Packing Biscuits (IOI20_biscuits)C++17
44 / 100
22 ms1368 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MXK = 60;

ll count_tastiness(ll x, vector<ll> a) {
    a.resize(MXK);
    vector<ll> f(MXK);
    f[0] = 1;
    for(int i = 0; i < MXK; i++) {
        ll sm = 0;
        ll prev = 0;
        ll mx = 0;
        for(int j = i; j >= 0; j--) {
            // f[j] to f[i] transition
            sm += a[j] * (1LL << j);
            mx ^= 1LL << (i - j);
            ll nw = min((sm / x) >> j, mx);
            f[i + 1] += f[j] * max(0ll, nw + 1 - prev);
            prev = 2 * max(prev, nw + 1);
        }
    }
    return f[59];
}
#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...