#C3987. Max Finished Projects
Max Finished Projects
Max Finished Projects
You are given a number of test cases. For each test case, you are provided with the number of employees and a total number of compute hours available. Each employee has a list of projects and each project requires a certain number of compute hours to complete. You can work on the projects in any order and each project must be completed entirely in order to be counted.
Your task is to determine the maximum number of projects that can be fully completed across all employees for each test case. The projects can be completed in any order, and you may choose the ones with the smallest compute hours first to maximize the number of completed projects.
The problem can be understood using the following formula: Given a sorted list of project hours \(a_1, a_2, \ldots, a_n\) and a total compute hour budget \(C\), find the largest \(k\) such that \(\sum_{i=1}^{k} a_i \leq C\).
inputFormat
The input is read from standard input (stdin) and has the following format:
T N C k1 a11 a12 ... a1k1 k2 a21 a22 ... a2k2 ... kN aN1 aN2 ... aNkN
where:
T
is the number of test cases.- For each test case, the first line contains two integers:
N
(the number of employees) andC
(the total compute hours available). - Then follow
N
lines, each representing an employee. Each such line starts with an integerk
representing the number of projects for that employee, followed byk
integers denoting the compute hours required for each project.
outputFormat
For each test case, output a single line containing one integer — the maximum number of projects that can be completely finished.
The output is written to standard output (stdout).
## sample2
3 10
2 4 6
3 1 2 3
1 7
2 15
2 6 9
2 5 10
4
2
</p>