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>
using namespace std;
#define vc vector
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
ll min(ll a, ll b){return (a>b) ? b:a;}
long long count_tastiness(long long X, vc<long long> A){
ll x=X;
ll k=A.size();
ll mk=62;
vc<ll> a(mk); loop(i, 0, k) a[i+1]=A[i];
vc<ll> dp(mk, 0);dp[0]=1;
loop(ti, 1, mk){
dp[ti]=dp[ti-1];
if(a[ti]>=x) dp[ti]+=dp[ti-1];
else{
ll i=ti;
vc<ll> na=a;
pool(j, ti, 1){
ll rpot=((ll)1<<(i-j));
ll kok=min((x-na[i]) * rpot, na[j]- na[j]%rpot);
na[i]+=kok/rpot;
na[j]-=kok;
if(x>na[i]) na[j-1]+=2 * na[j], na[j]=0;
else{
if(na[j]>=x){dp[ti]+=dp[j];break;}
else{
dp[ti]+=dp[j-1];
i=j;
}
}
}
}
}
return (long long ) dp[mk-1];
}
# | 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... |