#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=62;
ll x;
map<ll, ll> dp;
vector<ll> pref;
ll Solve(ll n) {
if(n<=0)
return 0LL;
if(n==1)
return 1LL;
if(dp.find(n)!=dp.end())
return dp[n];
ll i=__lg(n-1);
ll ans=Solve((ll)(1<<i))+Solve(min(n,pref[i]/x+1)-(ll)(1<<i));
dp[n]=ans;
return dp[n];
}
ll count_tastiness(ll X, vector<ll> a) {
x=X;
dp.clear();
for(int i=0; i<(int)a.size(); ++i) {
if(i>0)
a[i]=a[i-1]+a[i]*(ll)(1<<i);
pref.pb(a[i]);
}
for(int i=0; i<60; ++i)
pref.pb(pref.back());
return Solve(pref.back());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1186 ms |
1276216 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |