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"biscuits.h"
#ifndef EVAL
#include"grader.cpp"
#endif
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x;
map<ll,ll>dp[61];
vector<ll>a;
ll rec(int pos,int cur){
if(pos==61)return 1ll;
if(dp[pos].count(cur))return dp[pos][cur];
auto it=dp[pos].lower_bound(cur);
if(true){
auto itt=it;
if(itt!=dp[pos].begin()){
itt--;
if(itt->second==it->second)return it->second;
}
}
dp[pos][cur]=rec(pos+1,(cur+a[pos])>>1);
if(a[pos]+cur>=x)dp[pos][cur]+=rec(pos+1,(a[pos]+cur-x)>>1);
return dp[pos][cur];
}
ll count_tastiness(ll X,vector<ll>A){
a=A;x=X;
a.resize(61);
for(int i=0;i<61;i++)dp[i].clear();
for(int i=0;i<60;i++)
if(a[i]>x){
ll tmp=(a[i]-x)>>1ll;
a[i+1]+=tmp;
a[i]-=(tmp<<1ll);
}
return rec(0,0);
}
# | 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... |