#include "biscuits.h"
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long count_tastiness(long long x, vector<long long> a) {
int n=0ll;
int ans=0ll;
int k=a.size();
vector<int> potrebno(k+1,0ll);
for(int i=0ll;i<k;i++)n+=a[i]*(1ll<<i);
for(int i=0ll;i<n/x+2ll;i++){
for(int j=k;j>=0;j--){
if(i&(1ll<<j))potrebno[j]=x;
else potrebno[j]=0ll;
}
bool ok=true;
if(potrebno[k]==x)potrebno[k-1ll]+=2ll*x;
for(int j=k-1ll;j>0ll;j--){
if(potrebno[j]<0ll || potrebno[j]>1000000000000000004ll){
ok=false;
break;
}
potrebno[j-1ll]+=2ll*max(0ll,potrebno[j]-a[j]);
if(potrebno[j-1ll]<0ll || potrebno[j-1]>1000000000000000004ll){
ok=false;
break;
}
}
if(!ok)continue;
//for(int j=0;j<k+1;j++)cout<<potrebno[j]<<' ';
//cout<<endl;
//cout<<i<<endl;
if(potrebno[0ll]<=a[0ll]){ans++;//cout<<i<<endl;
}
}
return ans;
}
# | 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... |