#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
using namespace std;
//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
constexpr static int MXK = 30;
ll count_tastiness(ll x, vector<ll> a)
{
while (a.size() < MXK-1)
a.pb(0);
for (int i = 0; i < MXK-2; i++)
{
ll change = max<ll>((a[i] - x) / 2, 0);
a[i+1] += change;
a[i] -= change * 2;
}
vector<ll> pf(MXK, 0);
for (int i = 1; i < MXK; i++)
pf[i] = pf[i-1] + (a[i-1] << (i-1));
int sz = min<int>(1e5 + 5, x+3);
vector<vector<ll>> dp(MXK, vector<ll>(sz, 0)); // Last open bit
dp[0][0] = 1;
for (int i = 1; i < MXK; i++)
for (int j = 0; j < i; j++)
for (int k = 0; k < sz; k++)
if (((pf[i] - pf[j] + (k<<(j-1)))>>(i-1)) >= x)
dp[i][((pf[i]-pf[j]+(k<<(j-1)))>>(i-1))-x] += dp[j][k];
ll res = 0;
for (int i = 0; i < MXK; i++)
for (int j = 0; j < x + 3; j++)
res += dp[i][j];
debug(dp, res);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
72 ms |
48176 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
21 ms |
5228 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
67 ms |
48340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
72 ms |
48176 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |