Problem1525--PIPI凑零钱

1525: PIPI凑零钱

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 226  Solved: 52
[Submit] [Status] [Web Board] [Creator:]

Description

PIPI有若干种纸币,每种纸币数量无限,他想知道最少用多少张纸币能够恰好凑齐t元。

Input

多组输入。
第一行输入纸币的种数n和目标金额t(1<=n<=15,0<=t<=1000)
第二行输入n个正整数,代表纸币的面值(不超过1000)。

Output

对于每组输入,输出恰好凑齐目标金额所用纸币的最少数量。
如果无论如何都不能凑齐,输出-1。

Sample Input

3 5
1 2 3

Sample Output

2

Source/Category

简单