Submission #308352

#TimeUsernameProblemLanguageResultExecution timeMemory
308352DormiPacking Biscuits (IOI20_biscuits)C++14
9 / 100
1099 ms180308 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...