#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
vector<long long> trans(const vector<long long>& a, long long sub) {
vector<long long> na = a;
na.pop_back();
if (a.back() - sub > 1) {
long long val = (a.back() - sub) / 2;
if (na.size() == 0) na.push_back(val);
else na.back() += val;
}
return na;
}
map<vector<long long>, long long> f;
long long solve(long long x, vector<long long> a) {
if (a.size() == 0) return 1;
if (f.count(a)) return f[a];
long long ret = 0;
if (a.back() >= x) {
ret += solve(x, trans(a, x));
}
ret += solve(x, trans(a, 0));
return f[a] = ret;
}
long long count_tastiness(long long x, vector<long long> a) {
f.clear();
for (int i = 0; i < (int) a.size(); ++i) {
if (a[i] > x) {
long long add = (a[i] - x) / 2;
a[i] = x;
if (i + 1 == (int) a.size())
a.push_back(add);
else
a[i + 1] += add;
}
}
reverse(a.begin(), a.end());
return solve(x, a);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1103 ms |
71928 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1102 ms |
36236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |