#include "biscuits.h"
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
ll count_tastiness(ll x, vector<ll> a) {
vector<unordered_map<ll, ll>> dp(61);
a.resize(61);
for (int i = 0; i < 60; ++i)
if (a[i] >= x) {
ll tak = (a[i] - x) / x / 2;
a[i + 1] += tak;
a[i] -= tak * 2 * x;
}
function<ll(int, ll)> dfs = [&](int k, ll v) {
if (k == 60) return 1LL;
if (dp[k].count(v))
return dp[k][v];
ll ret = dfs(k + 1, (v + a[k]) / 2);
if (v + a[k] >= x) ret += dfs(k + 1, (v + a[k] - x) / 2);
return dp[k][v] = ret;
};
return dfs(0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |