Minimum Cost To Buy Oranges
Array index 'i' denotes the cost of (i+1)kg packet. Example: cost is the cost of a 1kg packet of oranges.
The first line of each test case contains two single space-separated integers 'N' and 'W' where 'N' denotes the size of the array/list(cost), and 'W' is the bag's size. The second line of each test case contains 'N' single space-separated integers denoting the values of the cost.
Print the minimum cost to buy exactly W kg oranges. If it's impossible, print "-1".
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= N <= 1000 1 <= W <= 1000 -1 <= cost[i] <= 1000000 Time Limit: 1sec