Find the minimum cost of using the saws to remove all N trees. If it is impossible to remove all N trees print -1.
You are given N trees numbered 1 to N which need to be removed. There are Q saws such that each saw has a cost and some trees that it can remove. It is given that using the i th saw cost c[i]. Moreover, the i th saw can be used to remove SZ trees denoted by row A[i] input format : 1. First line contains an Integer N denoting the number of trees. 2. The next line contains an integer Q denoting the number of saws. 3. The next line contains an integer SZ, denoting the number of trees removed by each saw. 4. Each line i of the Q subsequent lines ( where 0<=i<=Q) contains an integer describing C[i] denoting the cost for using the i th saw. 5. Each line i of the Q subsequent lines (where 0<=i<=Q) contains SZ space separated integers denoting row A[i] such that each row describes the trees removed by the i th saw. Constraints: 1<= N <= 15 1 <= Q <= 500 1 <= SZ <= N 1 <= C[i] <=10^6 1 <= A[i][j] <= N Sample input : 3 2 2 2 8 2 3 1 2 Sample output : 10 Explanation : You can buy the two saws by cost 2 + 8 = 10 I don't have much time to solve this please help me.