#pragma GCC optimize("O4,Ofast")
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll, ll>
#define pb push_back
typedef long long ll;
typedef __int128 i128;
namespace{
ll k;
const ll mxN=63;
const ll inf=2e18;
const ll LOG=63;
ll a[LOG];
vll v[LOG+1];
}
long long count_tastiness(long long x, vector<long long> A) {
k=A.size();
for(ll i=0;i<LOG;i++){
v[i].clear();
}
memset(a, 0, sizeof(a));
for(ll i=0;i<k;i++){
a[i]=A[i];
}
ll ans=1;
v[0].pb(0);
ll sum=0;
ll lg=63-__builtin_clzll(inf/x);
for(ll i=0;i<=lg;i++){
sum+=a[i]*(1LL<<i);
for(auto &it:v[i]){
if((it+(1LL<<i)*a[i])>=(x*(1LL<<i))){
v[i+1].pb(it+(1LL<<i)*a[i]-x*(1LL<<i));
// cout<<(sum-(it+(1LL<<i)*a[i]-x*(1LL<<i)))/x<<'\n';
ans++;
}
v[i+1].pb(it+(1LL<<i)*a[i]);
}
}
// cout<<"_______\n";
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... |