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 <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mp make_pair
#define vii vector<vector<int>>
#define ll long long
// void count_tastiness(int64_t x, vector<int64_t> a) {
// int k = a.size();
// rep(i, 0, k - 1) {
// if (a[i] > 2) {
// }
// }
// }
long long count_tastiness(long long x, vector<long long> a) {
while (a.size() < 60) a.push_back(0);
vector<long long> b;
for (long long i: a) b.push_back(i);
for (int i = 1; i < 60; ++i) b[i] += b[i - 1] / 2;
long long dp[61];
dp[0] = 1;
for (int i = 0; i < 60; ++i) {
if (b[i] < x) {
dp[i + 1] = dp[i];
continue;
}
long long dpv = 0, k = max(0LL, x - a[i]) * 2;
for (int j = i; j > 0; --j) {
if (b[j - 1] >= k + x) dpv += dp[j - 1], k = max(0LL, k + x - a[j - 1]) * 2;
else k = max(0LL, k - a[j - 1]) * 2;
}
if (k == 0) ++dpv;
dp[i + 1] = dp[i] + dpv;
}
return dp[60];
}
# | 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... |