#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
int n;
map<pair<int, long long>, long long> memo;
long long Solve(int i, const vector<long long> &cnt, long long s) {
if (memo.count({i, s})) return memo[{i, s}];
if (i == (int)cnt.size()) {
// cerr << "br 1: " << s << '\n';
return 1LL;
}
long long ret;
ret = Solve(i + 1, cnt, (s + cnt[i]) / 2);
if (s + cnt[i] >= n) {
ret += Solve(i + 1, cnt, (s + cnt[i] - n) / 2);
}
return memo[{i, s}] = ret;
}
long long count_tastiness(long long n, vector<long long> a) {
::n = n;
long long s = 0;
for (int i = 0; i < (int)a.size(); ++i) {
if (a[i] > n + 1) {
if (i + 1 == (int)a.size()) a.emplace_back(0LL);
auto delta = (a[i] - n) / 2;
a[i + 1] += delta;
a[i] -= 2 * delta;
}
s += a[i] << i;
// cerr << a[i] << ' ';
}
// cerr << endl;
memo.clear();
return Solve(0, a, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
265 ms |
20712 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
16644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |