dp of size target + 1 with all elements set to 0 except dp[0] which is set to 1.types array.dp array from target down to 0.i in the dp array, iterate from the question's mark value v up to count * marks (where count is the number of questions of that type and marks is the mark value of that type), updating dp[i] by adding dp[i - v] to it.dp[target] as the result.