Submission #824384

#TimeUsernameProblemLanguageResultExecution timeMemory
824384ymmPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1 ms316 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) typedef long long ll; typedef std::pair<ll,ll> pll; using namespace std; const int N = 64; ll a[N], b[N]; map<pll,ll> mem; int n; ll solve(int k, ll mx) { mx = min(mx, (1ll<<k)-1); if (k == 0 || mx == 0) return 1; auto &ans = mem[pll(k, mx)]; if (ans) return ans; ans += solve(k-1, min(mx, b[k-1])); if (mx >= (1ll << (k-1))) ans += solve(k-1, min(mx - (1ll << (k-1)), b[k-1])); return ans; } long long count_tastiness(long long x, std::vector<long long> _a) { n = _a.size(); Loop (i,0,n) a[i] = _a[i]; ll sum = 0; Loop (i,0,n) { sum += a[i]<<i; b[i+1] = sum/x; } mem.clear(); return solve(n, b[n]); }
#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...