


1. The processes are numbered from 1 to 'N'.
2. The process with lowest arrival time will be scheduled first, followed by the next lowest arrival time, and so on.
3. If any two processes have the same arrival time, then you have to run the process based on the priority of the process. The highest priority process will be scheduled first, followed by the next highest priority, and so on.
4. If the two processes have the same priority, then you have to run the process with the lowest process number first.
The first line contains an integer ‘T’ which denotes the number of test cases or queries to be run. Then the test cases are as follows.
The first line of each test case contains ‘N’ space-separated integers denoting the Arrival Times.
The second line of each test case contains ‘N’ space-separated integers denoting the Burst Times.
The third line of each test case contains ‘N’ space-separated integers denoting the Priorities of the processes.
For each test case, print three lines:
The first line should contain ‘N’ space-separated integers denoting the order of the processes in which they are scheduled.
The second line should contain ‘N’ space-separated integers denoting the waiting time of the processes.
The third line should contain ‘N’ space-separated integers denoting the turnaround time of the processes.
Print the output of each test case in three separate lines.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
1 <= X, Y, Z <= 10^4
Where ‘T’ is the number of test cases, ‘N’ denotes the number of processes, ‘X’, ‘Y’, Z’ denotes the arrival time, burst time and priority of a process respectively.
Time Limit: 1 sec
Approach: In order to implement priority based scheduling, let us first understand what priority based CPU scheduling actually means.
Priority Scheduling basically is a non-preemptive algorithm. As the name suggests it is based on priorities given to the processes. The processes with a higher priority are processed first and ones with the lowest priority are processed at last.
The flow of processes in priority scheduling is:
Now, let’s recall some terms:
So, the algorithm for priority scheduling: