

import math





class 					__lowerCAmelCase	:




  def __init__(							self				,  lowerCAmelCase=0   )    ->					Union[str, Any]:  # a graph with Node 0,1,...,N-1
        '''simple docstring'''






        _lowercase      			=n
        _lowercase      			=[
            [math.inf for j in range(0				,  lowerCAmelCase   )] for i in range(0				,  lowerCAmelCase   )
        ]  # adjacency matrix for weight
        _lowercase      			=[
            [math.inf for j in range(0				,  lowerCAmelCase   )] for i in range(0				,  lowerCAmelCase   )
        ]  # dp[i][j] stores minimum distance from i to j




  def     A__	(							self				,  lowerCAmelCase				,  lowerCAmelCase				,  lowerCAmelCase   )    ->					int:
        '''simple docstring'''






        _lowercase      			=w




  def     A__	(							self   )    ->					Dict:
        '''simple docstring'''






        for k in range(0				,  self.n   ):
              for i in range(0				,  self.n   ):
                    for j in range(0				,  self.n   ):
                          _lowercase      			=min(self.dp[i][j]				,  self.dp[i][k] + self.dp[k][j]   )




  def     A__	(							self				,  lowerCAmelCase				,  lowerCAmelCase   )    ->					List[Any]:
        '''simple docstring'''






        return self.dp[u][v]


if __name__ == "__main__":
  lowercase_   							=  Graph(5)
  graph.add_edge(0, 2, 9)
  graph.add_edge(0, 4, 1_0)
  graph.add_edge(1, 3, 5)
  graph.add_edge(2, 3, 7)
  graph.add_edge(3, 0, 1_0)
  graph.add_edge(3, 1, 2)
  graph.add_edge(3, 2, 1)
  graph.add_edge(3, 4, 6)
  graph.add_edge(4, 1, 3)
  graph.add_edge(4, 2, 4)
  graph.add_edge(4, 3, 9)
  graph.floyd_warshall()
  graph.show_min(1, 4)
  graph.show_min(0, 3)





from __future__ import annotations

from statistics import mean
def 	a (     A__      :  list[int] ,  A__      :  list[int] ,  A__      :  int	)       -> list[int]:





      """simple docstring"""



      _lowercase      			=[0] * no_of_processes
      _lowercase      			=[0] * no_of_processes

      # Initialize remaining_time to waiting_time.

      for i in range(A__	):
            _lowercase      			=burst_time[i]
      _lowercase      			=[]

      _lowercase      			=0
      _lowercase      			=0

      # When processes are not completed,
      # A process whose arrival time has passed \
      # and has remaining execution time is put into the ready_process.
      # The shortest process in the ready_process, target_process is executed.

      while completed != no_of_processes:
            _lowercase      			=[]
            _lowercase      			=-1

            for i in range(A__	):
                  if (arrival_time[i] <= total_time) and (remaining_time[i] > 0):
                        ready_process.append(A__	)

            if len(A__	) > 0:
                  _lowercase      			=ready_process[0]
                  for i in ready_process:
                        if remaining_time[i] < remaining_time[target_process]:
                              _lowercase      			=i
                  total_time += burst_time[target_process]
                  completed += 1
                  _lowercase      			=0
                  _lowercase      			=(
                      total_time - arrival_time[target_process] - burst_time[target_process]
                  )
            else:
                  total_time += 1

      return waiting_time
def 	a (     A__      :  list[int] ,  A__      :  int ,  A__      :  list[int]	)       -> list[int]:





      """simple docstring"""



      _lowercase      			=[0] * no_of_processes
      for i in range(A__	):
            _lowercase      			=burst_time[i] + waiting_time[i]
      return turn_around_time


if __name__ == "__main__":
  print('[TEST CASE 01]')

  lowercase_   							=  4
  lowercase_   							=  [2, 5, 3, 7]
  lowercase_   							=  [0, 0, 0, 0]
  lowercase_   							=  calculate_waitingtime(arrival_time, burst_time, no_of_processes)
  lowercase_   							=  calculate_turnaroundtime(
      burst_time, no_of_processes, waiting_time
  )

  # Printing the Result
  print('PID\tBurst Time\tArrival Time\tWaiting Time\tTurnaround Time')
  for i, process_id in enumerate(list(range(1, 5))):
    print(
        f"{process_id}\t{burst_time[i]}\t\t\t{arrival_time[i]}\t\t\t\t"
        f"{waiting_time[i]}\t\t\t\t{turn_around_time[i]}"
    )
  print(f"\nAverage waiting time = {mean(waiting_time):.5f}")
  print(f"Average turnaround time = {mean(turn_around_time):.5f}")


