Short solution in Python


#1
def solve(self, A, B, C):
        memo = [0] * (max(A) + 1)
        for i in range(1, max(A) + 1):
            memo[i] = min( memo[i-B[d]] + C[d] for d in range(len(B)) if i - B[d] >= 0 )
        return sum(memo[i] for i in A)