제출 #633821

#제출 시각아이디문제언어결과실행 시간메모리
633821tabrPacking Biscuits (IOI20_biscuits)C++17
42 / 100
1088 ms15620 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

long long count_tastiness(long long x, vector<long long> a) {
    a.resize(62);
    for (int i = 0; i < 61; i++) {
        if (a[i] > x) {
            long long t = (a[i] - x) / 2;
            a[i] -= 2 * t;
            a[i + 1] += t;
        }
    }
    map<long long, long long> dp;
    dp[0] = 1;
    for (int i = 0; i < 61; i++) {
        map<long long, long long> new_dp;
        for (auto [k, v] : dp) {
            new_dp[(a[i] + k) / 2] += v;
            if (a[i] + k >= x) {
                new_dp[(a[i] + k - x) / 2] += v;
            }
        }
        swap(dp, new_dp);
    }
    return dp[0];
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    debug(count_tastiness(3, {5, 2, 1}));  // 5
    debug(count_tastiness(2, {2, 1, 2}));  // 6
    return 0;
}
#endif
#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...