Time limit exceed error

Bytelandian gold coins
Problem Code: COINS

problem is COINS Problem - CodeChef
I am getting a time limit error. my code is Online Compiler and IDE - GeeksforGeeks .
Although the code the working fine.

You are doing nothing but brute force. Apply basic concept of dynamic programming and store any previously computed results. Since you are doing it in C++, try learning about the data structure “map” and see how it can help.

[Hint: Store the results and directly use them to avoid re-computing same thing again and again, which nnecessarily consumes time.]

Since i am new to programming i didn’t understand much of what you said.Please explain a bit in detail

If you are new to programming, why are you starting with a medium level Q in first place? :confused:

Anyway, google out the terms which you didnt understand, else the answer will be too verbose.