Submission #354416

#TimeUsernameProblemLanguageResultExecution timeMemory
354416Osama_AlkhodairyPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1100 ms57388 KiB
#include <bits/stdc++.h>
#include "biscuits.h"
//~ #include "grader.cpp"
using namespace std;
#define ll long long

int k;
ll x;
map <ll, ll> dp[61];
vector <ll> a;

ll solve(int idx, int p){
    if(idx == k) return 1;
    if(dp[idx].find(p) != dp[idx].end()) return dp[idx][p];
    ll &ret = dp[idx][p];
    ret = 0;
    ll f = a[idx] + p;
    ret += solve(idx + 1, f / 2);
    if(f >= x){
        ret += solve(idx + 1, (f - x) / 2);
    }
    return ret;
}
long long count_tastiness(long long X, vector<long long> A){
    x = X;
    a = A;
    k = a.size();
    while(k < 60){
        a.push_back(0);
        k++;
    }
    for(int i = 0 ; i < 61 ; i++){
        dp[i].clear();
    }
    for(int i = 0 ; i < k ; i++){
        if(a[i] <= x) continue;
        ll f = a[i] - x;
        f -= f % 2;
        a[i] -= f;
        if(i + 1 < k) a[i + 1] += f / 2;
    }
    return solve(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...