Submission #590083

#TimeUsernameProblemLanguageResultExecution timeMemory
590083LucppPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1091 ms63212 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<map<ll, ll>> dp; ll calc(int i, ll cnt){ if(i == k) return 1; if(dp[i].count(cnt)) 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.clear(); dp.resize(k); 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...