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