# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
583185 | joelau | Packing Biscuits (IOI20_biscuits) | C++14 | 73 ms | 1324 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 <bits/stdc++.h>
using namespace std;
long long X;
vector<long long> sum;
map<long long,long long> memo;
long long dp (long long x) {
if (x < 0) return 0;
if (x == 0) return 1;
if (x == 1) return 1 + (sum[0] >= X);
if (memo.find(x) != memo.end()) return memo[x];
long long n = 0;
while ((1ll<<(n+1)) <= x) n++;
return memo[x] = dp((1ll<<n)-1) + dp(min(x,sum[n]/X)-(1ll<<n));
}
long long count_tastiness(long long x, vector<long long> a) {
sum.clear(); memo.clear();
while (a.size() <= 60) a.push_back(0);
sum.push_back(a[0]);
for (long long i = 1; i < a.size(); ++i) sum.push_back(sum.back() + a[i] * (1ll<<i));
X = x;
return dp(1ll<<60);
}
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... |