#include "biscuits.h"
#include <iostream>
#define int long long
using namespace std;
int count_tastiness(int x, vector<int> a)
{
vector<int> dpref(63);
vector<int> vpref(63);
vector<int> dp(62);
a.resize(64);
int v = 0;
int pw = 1;
int m = 60;
for (int i = 0; i < m; i++, pw *= 2)
{
v += a[i]*pw;
vpref[i] = v;
int b = v - pw*x;
int np = pw / 2;
// cerr << "Starting " << i << ": " << v << " " << b << "\n";
for (int j = i - 1; j >= 0; j--, np /= 2)
{
// cerr << " -> " << j << " " << b << " " << np << "\n";
if (b >= np*x && vpref[j] >= np * x)
{
b -= np*x;
dp[i] += 1 + dpref[j];
}
}
if (b >= 0) dp[i]++;
dpref[i + 1] = dpref[i] + dp[i];
// cerr << i << " " << dp[i] << " " << dpref[i] << "\n";
}
return dpref[m] + 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |