# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303278 | ecnerwala | Packing Biscuits (IOI20_biscuits) | C++17 | 29 ms | 1016 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 <vector>
#include <iostream>
long long count_tastiness(long long X, std::vector<long long> A) {
auto get_A = [&](int i) { return i < int(A.size()) ? A[i] : 0; };
std::vector<long long> len(121);
len[0] = 1;
std::vector<long long> max_elt(121); // floor of the max element
max_elt[0] = 0;
for (int i = 0; i < 120; i++) {
max_elt[i+1] = (get_A(i) + max_elt[i]) / 2;
len[i+1] = 0;
long long cutoff = 0;
for (int j = i; j >= 0; j--) {
cutoff *= 2;
cutoff -= get_A(j);
if (max_elt[j] >= cutoff + X) {
len[i+1] += len[j];
cutoff += X;
}
cutoff = std::max(cutoff, 0ll);
}
len[i+1]++; // the final 0
}
return len.back();
}
# | 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... |