There are two applications running on a multiprocessor machine. Each application i (i=1,2) consists of N procedures which are numbered from 1 to N and must be executed sequentially (in the order 1,...,N). A procedure will be identified by a pair (i,j), where i=1,2 identifies the application and 1≤j≤N represents the index of the procedure in the sequence of procedures of the application i. A procedure (i,j) can only be executed on the processor P(i,j) of the machine and its execution lasts for D(i,j) seconds. We want to schedule the execution of the procedures of the two applications over the processors of the machine in such a way that the time moment when the last procedure finishes its execution (from any of the two applications) is minimum; this time moment is called makespan. We consider that the two applications are available for scheduling starting from the time moment 0. The schedule needs to obey the following rules:
once the execution of a procedure (i,j) starts on the processor P(i,j), we cannot interrupt it until the execution of the procedure ends
we cannot execute multiple procedures on the same processor at the same time, but we can execute multiple procedures in parallel on different processors
the execution of the procedure (i,j) (2≤j≤N) starts either at the exact time moment tm when the procedure (i,j-1) finishes its execution or at any time moment after tm
if a procedure begins its execution at time moment tm, then it will finish its execution at the time moment tm+D(i,j)
Write a program that, given the information regarding the procedures of the two applications, computes the minimum makespan.