#P9234. [蓝桥杯 2023 省 A] 买瓜
[蓝桥杯 2023 省 A] 买瓜
Problem Description
Xiao Lan is buying melons at a melon stall. There are melons in total, and the weight of the -th melon is . Xiao Lan is very skilled with a knife: he can split any melon into two exactly equal halves, but each melon can only be cut once.
Xiao Lan wants the total weight of the melons he buys to be exactly .
Please output the minimum number of melons Xiao Lan needs to cut to obtain melons with total weight exactly . If no matter what he does he cannot obtain melons with total weight exactly , output .
Input Format
The first line contains two integers , separated by a space, representing the number of melons and the total weight Xiao Lan wants to buy.
The second line contains integers , separated by spaces, representing the weight of each melon.
Output Format
Output one line containing one integer, the answer.
3 10
1 3 13
2
Hint
Constraints
For of the testdata, .
For of the testdata, .
For all testdata, , , .
Translated by ChatGPT 5