int get(int curr,int n,int x,int y,int z){
if(curr==n)
return 0;
if(curr>n)
return (curr-n)z;
if(dp[curr]!=-1)
return dp[curr];
int ans=INT_MAX;
ans=min(ans,x+get(2curr,n,x,y,z));
ans=min(ans,y+get(curr+1,n,x,y,z));
return dp[curr]=ans;
}
int get(int curr,int n,int x,int y,int z){
if(curr==n)
return 0;
if(curr>n)
return (curr-n)z;
if(dp[curr]!=-1)
return dp[curr];
int ans=INT_MAX;
ans=min(ans,x+get(2curr,n,x,y,z));
ans=min(ans,y+get(curr+1,n,x,y,z));
return dp[curr]=ans;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.