In batch programming, there are many tasks that need to be completed in minimal overall time. Accurate information about the total runtime and interdependencies of processes is often available to the scheduler, allowing optimal schedulings to be found. This problem considers processes that can run on different CPUs at the same time, but which are interdependent. That is to say, some processes cannot start until others have completed. Scheduling processes optimally prevents CPUs from being idle unnecessarily.
Your task is to find a way of using n processors to run p processes, minimizing the number of time slices until they are all finished. Some processes may be dependent on processes that depend on other processes, but there will be no dependency loops.
There will be p additional lines representing the processes. Each of these lines will contain an integer representing the number of CPU time slices required for the process and zero or more integers representing the processes that must finish before this process may start. Processes are numbered from 1 to p.
3 5 4 3 2 4 2 2 1 1 3
1 1 2 1 1 2 4 4 2 3 3 5