Coins - MarisaOJ: Marisa Online Judge

Coins

Time limit: 1000 ms
Memory limit: 256 MB
There are $n$ types of coins in Gensokyo. The $i^{th}$ type is worth $A_i$. Marisa has to pay a debt of $k$, so what is the minimum number of coins she has to use? ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ distinct integers $A_i$. ### Output - Print one integer, the minimum number of coins, or print `-1` if there is no way to product $k$ using the given type of coins. ### Constraints - $1 \le n \le 1000$. - $1 \le k \le 10^5$. - $1 \le A_i \le 10^5$. ### Example Input: ``` 3 11 1 5 7 ``` Output: ``` 3 ```