This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 62;
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)
{
b = min(b, vpref[j]);
if (b >= np*x && vpref[j] >= np * x)
{
// cerr << " -> Take " << j << " (add " << 1 + dpref[j] << ") " << "\n";
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |