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> pref(63);
vector<int> dp(62);
a.resize(64);
int v = 0;
int pw = 1;
for (int i = 0; i < 62; i++, pw *= 2)
{
v += a[i]*pw;
int b = v - pw*x;
int np = pw / 2;
for (int j = i - 1; j >= 0; j--, np /= 2)
{
if (b >= np*x)
{
b -= np*x;
dp[i] += 1 + pref[j];
}
}
if (b >= 0) dp[i]++;
pref[i + 1] = pref[i] + dp[i];
}
return pref.back() + 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... |