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 <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
//#include "biscuits.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll s[65],dp[65][65],x,a[105];
ll solve(ll bit,ll nr){
if(bit==-1)return 1;
ll &val=dp[bit][nr];
if(val!=-1) {
return val;
}
ll b=s[nr]&((1ll<<(bit+1))-1);
if(b>s[bit]){
b=s[bit];
nr=bit;
}
val=0;
if((1ll<<bit)>b){
val+=solve(bit-1,nr);
}else {
val+=solve(bit-1,bit-1)+solve(bit-1,nr);
}
return val;
}
ll count_tastiness(ll X,vector<ll>A){
x=X;
memset(a,0,sizeof(a));
for(ll i=0;i<A.size();i++)
a[i]=A[i];
for(ll i=0;i<60;i++)
s[i]=(1ll<<i)*a[i];
for(ll i=1;i<60;i++)
s[i]+=s[i-1];
for(ll i=0;i<60;i++)
s[i]/=x;
for(ll i=0;i<60;i++)
s[i]=min(s[i],(1ll<<(i+1))-1);
memset(dp,-1,sizeof(dp));
return solve(59,59);
}
/*
int32_t main(){
CODE_START;
*/
Compilation message (stderr)
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:48:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(ll i=0;i<A.size();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... |