Submission #726955

#TimeUsernameProblemLanguageResultExecution timeMemory
726955NemanjaSo2005Packing Biscuits (IOI20_biscuits)C++14
0 / 100
9 ms10852 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int MaxN=60; ll N,K,res,kol[MaxN*4],stepen[MaxN*4],dp[MaxN+5][10010]; ll count_tastiness(ll k,vector<ll> A){ stepen[0]=1; for(int i=1;i<=MaxN;i++) stepen[i]=stepen[i-1]*2; for(int i=MaxN+1;i<MaxN*4;i++) stepen[i]=1; K=k; res=1; N=A.size(); for(int i=0;i<N;i++) kol[i]=A[i]; for(int i=N;i<4*MaxN;i++) kol[i]=0; for(int i=0;i<4*MaxN;i++) if(kol[i]>k+1){ kol[i+1]+=(kol[i]-k)/2; kol[i]=k+kol[i]%2; } int M=2*K+2; memset(dp,0,sizeof(dp)); for(int i=0;i<=M;i++) if(i+K<=kol[0]) dp[0][i]=2; else if(i<=K) dp[0][i]=1; else dp[0][i]=0; for(int i=1;i<N;i++){ for(int j=0;j<=M;j++){ ll r=0; /// Ne delis ga if(j<=kol[i]) r+=dp[i-1][0]; else if((j-kol[i]*2)<=M) r+=dp[i-1][(j-kol[i])*2]; /// Delis ga if(j+K<=kol[i]) r+=dp[i-1][0]; else if((j+K-kol[i])*2<=M) r+=dp[i-1][(j+K-kol[i])*2]; dp[i][j]=r; } } return dp[N-1][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...