Let's say we've got an input:
10 // saying 1st property should be 10(in total)
10 // saying 2d property should be 10 (in total)
5 // saying theres 5 records below
// (1st property) (2nd property) (cost)
2 5 8
7 3 10
4 2 9
4 3 5
8 5 15
In this case, the output would look like that:
22 // lowest possible cost
1 3 4 // indexes of records, we've been using (indexing starts with 1)
2 5 8
4 2 9
4 3 5
+---------
10 10 22
If there wasn't possible way to achieve those properties to be 10 and 10, program would output -1; I do know how to solve knapsack problem, however I've got no clue how to solve this prob.