CT36894

The Umber Exact Tender

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the island market of Coralcove, someone must certify the cargo before shipping. This year the task falls to Vera, armed only with the vaults register. Task: Coins of n given sizes may be used without limit. Print the minimum number of coins summing exactly to amount, or -1. Input format: First line: amount and n. Second line: n distinct coin sizes. Output format: Print the minimum coin count, or -1. Constraints: 0 <= amount <= 10000; 1 <= n <= 50; 1 <= coin <= 10^4.

Example 1:

Input: 2494 3 1 5980 8596
Output: 2494

Example 2:

Input: 7758 3 3509 5312 6379
Output: -1

Example 3:

Input: 2408 3 1 4934 6560
Output: 2408

Constraints:

0 <= amount <= 10000; 1 <= n <= 50; 1 <= coin <= 10^4.

Loading...
Test Cases:No test cases
No test cases available.
The Umber Exact Tender - MEDIUM Coding Problem | CodeTikki