0

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.

7th Mar 2022, 5:22 AM
Anna Hari
Anna Hari - avatar
3 odpowiedzi
+ 1
Hi! Seriously, you don't have enough time to do your homeworks? That's not fair for a student. Please don't use discussion forums to do something like this. At least, provide a minimal reproducible example. There are better places where people help you to complete your homework for money.
7th Mar 2022, 5:50 AM
Python Learner
Python Learner - avatar
0
Hello. Could you please show us your attempt? With all due respect, this looks like a test paper exercise. :))
7th Mar 2022, 5:48 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
0
This is not homework
7th Mar 2022, 5:54 AM
Anna Hari
Anna Hari - avatar