이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |