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 count_tastiness(long long x, vector<long long> a) {
int n = (int) a.size();
vector<long long> pref(n);
pref[0] = a[0];
for (int i = 1; i < n; i++) {
pref[i] += pref[i - 1] + a[i] * (1LL << i);
}
vector<long long> dp(n);
function<void(int)> Solve = [&](int b) {
if (b == 0) {
dp[b] = pref[b];
return;
}
Solve(b - 1);
if (a[b] == 0) {
dp[b] = dp[b - 1];
return;
}
dp[b] = (dp[b - 1] + 1) * (a[b] + 1 - min(a[b], pref[b - 1] / (1LL << b)));
};
Solve(n - 1);
return dp[n - 1] + 1;
}
# | 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... |