Submission #590089

#TimeUsernameProblemLanguageResultExecution timeMemory
590089LucppPacking Biscuits (IOI20_biscuits)C++17
33 / 100
973 ms2097152 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int k = 60; ll x; vector<ll> a; vector<vector<ll>> dp; ll calc(int i, ll cnt){ if(i == k) return 1; if(dp[i][cnt] != -1) return dp[i][cnt]; ll ans = 0; if(cnt+a[i] >= x){ ans += calc(i+1, (cnt+a[i]-x)/2); } ans += calc(i+1, (cnt+a[i])/2); return dp[i][cnt] = ans; } ll count_tastiness(ll x_, vector<ll> a_) { x = x_; a = a_; a.resize(k); for(int i = 0; i < k; i++){ if(a[i] <= x+1) continue; ll cnt = (a[i]-x)/2; a[i] -= 2*cnt; a[i+1] += cnt; } dp.assign(k, vector<ll>(2*x, -1)); return calc(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...