#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=61;
map<ll, ll> dp;
ll pref[N], x;
ll Solve(ll n) {
cout << n << '\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));
return dp[n]=ans;
}
ll count_tastiness(ll X, vector<ll> a) {
x=X;
dp.clear();
for(int i=0; i<(int)a.size(); ++i)
pref[i]=(i>0?pref[i-1]:0LL)+a[i]*(ll)(1<<i);
for(int i=(int)a.size(); i<=60; ++i)
pref[i]=pref[i-1];
return Solve(pref[60]);
//return 1;
}
/*int main() {
cout << count_tastiness(3, {5, 2, 1});
}*/
# |
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 |
1096 ms |
322764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1113 ms |
356224 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 |
- |