#include "biscuits.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
ll X;
long long count_tastiness(long long _X, std::vector<long long> a)
{
vi b;
X = _X;
for (int i = 0; i < sz(a); ++i)
{
b.push_back(a[i]);
if (b[i] >= X)
{
ll remove = ((a[i] - X) / 2) * 2;
b[i] -= remove;
if (i + 1 >= sz(a))
a.push_back(0);
a[i + 1] += remove / 2;
}
}
if (b.back() != 0)
b.push_back(0);
vvi dp(sz(b), vi(X + 2, 0));
// b.back() == 0
for (int j = 0; j < sz(dp.back()); ++j)
dp.back()[j] = 1;
dp.back()[X] = 2;
dp.back()[X + 1] = 2;
for (int i = sz(b) - 2; i >= 0; --i)
{
for (int j = 0; j < sz(dp[i]); ++j)
{
ll vorrat = b[i] + j;
dp[i][j] += dp[i + 1][vorrat / 2]; // mache nichts
if (vorrat >= X)
dp[i][j] += dp[i + 1][(vorrat - X) / 2]; // set a bit
}
}
return dp[0][0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4968 KB |
Output is correct |
2 |
Correct |
5 ms |
2460 KB |
Output is correct |
3 |
Correct |
6 ms |
3380 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
19 ms |
5108 KB |
Output is correct |
9 |
Correct |
12 ms |
3264 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
948 KB |
Output is correct |
13 |
Correct |
19 ms |
5104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1061 ms |
1027740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |