CSES - Most coins

You are given nn coin values and a sum xx. Find the maximum number of coins that sum up to xx.

You may assume that 1n101 \le n \le 10 and that 1x1001 \le x \le 100. One of the coin values is always 11. The algorithm should be efficient for all these cases.

In a file maxcoin.py, implement a function find that returns the desired count.

def find(x, coins):
    # TODO

if __name__ == "__main__":
    print(find(5, [1, 2, 5])) # 5
    print(find(10, [1])) # 10
    print(find(8, [1, 2, 3, 4, 5])) # 8

Explanation: When x=5x=5 and the coins are [1,2,5][1,2,5], the optimal solution is [1,1,1,1,1][1,1,1,1,1], which contains 55 coins.