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;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
int sz(const T &a){return int(a.size());}
const int MAXN=62;
map<ll,ll> dp[MAXN];
ll am[MAXN];
ll maxam[MAXN];
ll x;
ll solve(int loc, ll wanted){
if(wanted>maxam[loc])return 0;
if(loc==0){
ll ans=0;
if(am[loc]>=wanted)ans++;
if(am[loc]-x>=wanted)ans++;
return ans;
}
if(dp[loc].count(wanted))return dp[loc][wanted];
return dp[loc][wanted]=solve(loc-1,ll(2)*max(ll(0),wanted-am[loc]))+solve(loc-1,ll(2)*max(ll(0),wanted+x-am[loc]));
}
ll count_tastiness(ll X, vector<ll> a){//maytlenotsure
x=X;
int n=sz(a);
for(int i=0;i<=60;i++){
dp[i]=map<ll,ll>();
if(i<n)am[i]=a[i];
else am[i]=0;
}
maxam[0]=am[0];
for(int i=1;i<=60;i++){
maxam[i]=maxam[i-1]/2+am[i];
}
return solve(60,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... |