Question: A processor is given a lineup of processes to complete in a FIFO manner ( which means the first process is to be executed before
A processor is given a lineup of processes to complete in a FIFO manner which means the first process is to be executed before the second, and so onEach process requires number of cycles for it to be completed. However, the processor allocates a limit of cycles to each process at a time. If a process isn't completed within the cycles, it will be paused and then placed behind the current last process in the lineup. When the processor comes back to this process, it will continue the execution of the process from where it was paused.Following the above steps, one of the processes will surely be completed first before all the others. Given the and the list of s determine the cycle time at which the first process is completed.Input FormatTwo lines. The first contains the integers: l n; which indicates the processor's cycle limit and the number of processes. The second line contains n space separated integers denoting ; which are the number of cycles respectively needed by the process.Constraints for Output FormatOne line with the first time at which the processor finishes a process.Sample Input Sample Output Explanation There are processes and the processor allocates cycles to each at a time.At the cycle, the first process has been executed, however it is not completed. So it is paused and added back to the process lineup, behind the process, with an updated cycle number of since it doesn't need to be started all over again.Following the above procedure up to the cycle, the status of the processes will be as followed:At the cycle, the nd process will be the first to have been completed. So the time is returned.Contest ends in a daySubmissions: Max Score: Difficulty: EasyRate This Challenge: More #binpythonimport mathimport osimport randomimport reimport sysif namemain: ln inputrstripsplit l intln n intln processes listmapint inputrstripsplit
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
