Submission #789518

#TimeUsernameProblemLanguageResultExecution timeMemory
789518borisAngelovPacking Biscuits (IOI20_biscuits)C++17
21 / 100
1089 ms53044 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; const int maxn = 65; int n; long long x; long long a[maxn]; struct key // last hope to cheat { int pos; long long carry; inline friend bool operator < (const key& x, const key& y) { return x.pos < y.pos || (x.pos == y.pos && x.carry < y.carry); } }; map<key, long long> dp; long long f(int pos, long long carry) { if (pos == n) { return carry / x + 1; } if (dp.count({pos, carry}) != 0) { return dp[{pos, carry}]; } long long curr = carry + a[pos]; long long ans = f(pos + 1, curr / 2); if (curr >= x) { ans += f(pos + 1, (curr - x) / 2); } return dp[{pos, carry}] = ans; } long long count_tastiness(long long X, vector<long long> arr) { dp.clear(); n = arr.size(); x = X; for (int i = 0; i < n; ++i) { a[i] = arr[i]; } return f(0, 0); } /* 1 3 3 5 2 1 1 3 2 2 1 2 2 3 3 5 2 1 3 2 2 1 2 */
#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...