Paying in a shop

You really like paying with as few coins as possible when doing groceries. You have several 50s, some 20s, some 10s, 5s, and also 1s.
Given your whole purchase total t, what is the minimum number of coins needed to pay for groceries (It’s guaranteed that you have enough money for that)?
Input
Output
51
2
111
4
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue