How to solve the problem using dynamic programming

  Kiến thức lập trình

Spiderman in Trouble
The Amazing Spiderman wants to create web fluid for himself before fight with Electro. He initially has
of web fluid. Spiderman wants to create
of web fluid. So he can change the amount of fluid in 3 different ways -:

  1. Double the amount of fluid.
  2. Increase the fluid by
    .
  3. Decrease the fluid by
    .

Now, all the above operations have different costs associated with them
respectively for above operations. Help spiderman in finding the minimum cost to generate
of fluid starting from
of fluid.
Note: You need to generate exactly
of web fluid.
Input
Each test case contains 2 lines. First lines contains an integer N Second lines contains 3 space separated integers
, and

Output
Print an integer denoting the minimum cost incurred
Maximize
of web fluid.

Any leads on solving the problem is appreciated . Tried a dynamic programming approach but didnt work correctly.

New contributor

ROJIN RAJ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT