Submission #529358

#TimeUsernameProblemLanguageResultExecution timeMemory
529358PurpleCrayonPacking Biscuits (IOI20_biscuits)C++17
33 / 100
684 ms1528 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define sz(v) int(v.size()) typedef long long ll; long long count_tastiness(long long x, std::vector<long long> a) { int k = sz(a); assert(x <= int(1e4)); map<ll, ll> dp; dp[0] = 1; auto add = [&](ll A) { map<ll, ll> ndp; for (auto& [c, v] : dp) { // place a 0 ndp[(A + c) / 2] += v; // place a 1 if (A + c >= x) ndp[(A + c - x) / 2] += v; } dp = ndp; }; for (int i = 0; i < k; i++) { add(a[i]); } while (prev(dp.end())->first) { add(0); } ll ans = 0; for (auto& [k, v] : dp) ans += v; return ans; }
#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...