let coin_min coins amount =
  let dp = Array.make (amount + 1) (-1) in
  dp.(0) <- 0;
  for i = 1 to amount do
    List.iter (fun c ->
      if c <= i && dp.(i - c) >= 0 then begin
        let cand = dp.(i - c) + 1 in
        if dp.(i) < 0 || cand < dp.(i) then dp.(i) <- cand
      end
    ) coins
  done;
  dp.(amount)

;;

coin_min [1; 5; 10; 25] 67
