Submission #1028791

#TimeUsernameProblemLanguageResultExecution timeMemory
1028791hmm789Packing Biscuits (IOI20_biscuits)C++14
0 / 100
2 ms348 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long s[60], x; unordered_map<long long, long long> memo; long long dp(long long n) { if(n == 1) return 1; if(n <= 0) return 0; if(memo.count(n)) return memo[n]; int bt = 63-__builtin_clzll(n-1); long long pw = 1LL<<bt; return memo[n] = dp(pw) + dp(min(n, 1+s[bt]/x)-pw); } long long count_tastiness(long long X, vector<long long> a) { x = X; int k = (int)a.size(); s[0] = a[0]; for(int i = 1; i < k; i++) s[i] = s[i-1] + a[i]*(1LL<<i); memo.clear(); return dp(s[k-1]+1); }
#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...