Oree's Candies
Oree's white van recently broke down, hindering him from selling candies in his local neighbourhood. Without any other form of transport, he has no choice but to carry the candies in a bag and walk around with them.
Oree, being a wizard, has crafted some very special candies. They are super flavourful, and some candies are more flavourful than others. The more flavourful a candy is, the more addictive, and hence, the higher likelihood that he will get repeat customers. However, without his white van, he cannot deliver as many candies as before.
He sets himself a goal to sell candies that have a combined total of flavour factor. No more, no less. He also wants to carry the least amount of candy needed to achieve this, since he doesn't want to carry too many candies.
Input
The first line contains two integers
and
, the different flavour factors of candies available, and the flavour goal to meet.
The next line contains integers
, the flavour factors available. The provided flavour factors are unique (i.e., there are no duplicates).
Output
Output the number of candies he needs to carry in order to meet his flavour factor goal. If it's not possible to achieve this goal, output .
Example
Input 1
4 20
1 4 6 8
Output 1
3
Oree can get two candies with a flavour factor of and one candy with a flavour factor of
to reach his goal of
total flavour factor.
Input 2
1 3
2
Output 2
-1
It is not possible to get exactly total flavour factor with candies that have a flavour factor of
.
Comments