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<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[65], lim[65], X;
map<ll, ll> dp[65];
ll calc(ll i, ll j){
j = min(j, 2*X);
if(dp[i][j]) return dp[i][j];
if(j >= X){
if(i > 0) dp[i][j] += calc(i-1, min(lim[i], j-X) * 2 + arr[i-1]);
else dp[i][j]++;
}
if(i > 0) dp[i][j] += calc(i-1, min(lim[i], j) * 2 + arr[i-1]);
else dp[i][j]++;
return dp[i][j];
}
ll count_tastiness(long long x, std::vector<long long> a) {
memset(arr, 0, sizeof(arr));
memset(lim, 0, sizeof(lim));
for(int i=0;i<63;i++) dp[i].clear();
X = x;
for(int i=0;i<a.size();i++) arr[i] = a[i];
for(int i=0;i<62;i++) lim[i+1] = arr[i]/2, arr[i+1] += arr[i]/2, arr[i] %= 2;
return calc(62, arr[62]);
}
Compilation message (stderr)
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i=0;i<a.size();i++) arr[i] = a[i];
| ~^~~~~~~~~
# | 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... |