# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782577 | _martynas | Packing Biscuits (IOI20_biscuits) | C++14 | 3 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "biscuits.h"
#include <set>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
using namespace std;
using ll = long long;
#warning change mxk to 60
const int mxk = 60;
unordered_map<ll, ll> memo;
ll solve(ll n, ll x, vector<ll> &pref) {
if(n == 1) return 1;
if(n <= 0) return 0;
if(memo.count(n)) return memo[n];
ll val = 0;
int msb = 31-__builtin_clz(n-1);
val += solve(1LL<<msb, x, pref);
val += solve(min(n, 1+pref[msb]/x)-(1LL<<msb), x, pref);
memo[n] = val;
return val;
}
ll count_tastiness(ll x, vector<ll> a) {
memo.clear();
vector<ll> pref(mxk);
for(int i = 0; i < a.size(); i++) {
pref[i] = (1LL<<i)*a[i]+(i?pref[i-1]:0);
}
ll ans = solve(1LL<<mxk, x, pref);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |