## LKP '18 Contest 1 P1 - World Trade Foundation

View as PDF

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type

The World Trade Foundation has denominations of coins, where is a multiple of for . The WTF wishes to perform a transaction that costs exactly Quunar (the local currency). Because they value efficiency over all else, determine the minimum number of coins they need to get exactly Quunar, or print -1 if this is not possible.

#### Constraints

It is guaranteed that is a multiple of .

#### Input Specification

On the first line, there are two space-separated integers, .
The next line contains space-separated integers, , the values of the coins (in Quunar).

#### Output Specification

On one line, output the minimum number of coins needed to make a sum of exactly Quunar or print -1 if this is not possible.

#### Sample Input 1

3 10
1 2 4

#### Sample Output 1

3

#### Sample Input 2

5 263
1 5 10 50 100

#### Sample Output 2

7

#### Sample Input 3

3 7
2 6 12

#### Sample Output 3

-1