Submission #315670

#TimeUsernameProblemLanguageResultExecution timeMemory
315670SortingPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1092 ms39832 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x, k; vector<ll> a; map<pair<int, ll>, ll> dp; ll solve(int idx, ll add){ //cout << "solve " << idx << " " << add << endl; if(idx == k) return (add / x) + 1; if(dp.count({idx, add})) return dp[{idx, add}]; ll &ans = dp[{idx, add}]; ll sum = a[idx] + add; if(sum < x) ans = solve(idx + 1, sum >> 1); else ans = solve(idx + 1, sum >> 1) + solve(idx + 1, (sum - x) >> 1); return ans; } ll count_tastiness(ll _x, vector<ll> _a){ dp.clear(); x = _x, a = _a; k = a.size(); 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...