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;
const long long LINF = (long long) 1e18;
#ifdef DEBUG
#include "../../../templates/debug.h"
#else
#define debug(...) 0
#endif
long long count_tastiness(long long x, std::vector<long long> a) {
const int k = 62;
while ((int) a.size() < k) a.push_back(0);
a.insert(a.begin(), 0ll);
vector<long long> b = a;
for (int i = 1; i <= k; i++) b[i] += b[i - 1] / 2;
b[0] = LINF;
vector<long long> dp(k + 1, 1); dp[0] = 1;
for (int i = 1; i <= k; i++) {
if (b[i] < x) {
dp[i] = dp[i - 1];
continue;
}
long long taken = max(0ll, x - a[i]) * 2;
dp[i] = dp[i - 1] + 1;
for (int j = i - 1; j >= 1; j--) {
if (b[j] - taken >= x) {
dp[i] += dp[j - 1];
taken = (max(0ll, taken + x - a[j])) * 2;
} else taken = max(0ll, taken - a[j]) * 2;
}
}
return dp[k];
}
# | 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... |