'''simple docstring'''


import os
from math import logaa





def       lowerCAmelCase					(		UpperCamelCase__				:   str = "base_exp.txt"       ):


	"""simple docstring"""
	__UpperCAmelCase							=			0
	__UpperCAmelCase							=			0
	for i, line in enumerate(open(os.path.join(os.path.dirname(UpperCamelCase__       )    ,					UpperCamelCase__       )       )       ):
		__UpperCAmelCase				,			__UpperCAmelCase							=			list(map(UpperCamelCase__    ,					line.split(''','''       )       )       )
		if x * logaa(UpperCamelCase__       ) > largest:
			__UpperCAmelCase							=			x * logaa(UpperCamelCase__       )
			__UpperCAmelCase							=			i + 1
	return result


if __name__ == "__main__":
					print(solution())

'''simple docstring'''


from __future__ import annotations

from statistics import mean





def       lowerCAmelCase					(		UpperCamelCase__				:   list[int]    ,					UpperCamelCase__				:   list[int]    ,					UpperCamelCase__				:   int       ):


	"""simple docstring"""
	__UpperCAmelCase							=			[0] * no_of_processes
	__UpperCAmelCase							=			[0] * no_of_processes

	# Initialize remaining_time to waiting_time.

	for i in range(UpperCamelCase__       ):
		__UpperCAmelCase							=			burst_time[i]
	__UpperCAmelCase							=			[]

	__UpperCAmelCase							=			0
	__UpperCAmelCase							=			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:
		__UpperCAmelCase							=			[]
		__UpperCAmelCase							=			-1

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

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

	return waiting_time





def       lowerCAmelCase					(		UpperCamelCase__				:   list[int]    ,					UpperCamelCase__				:   int    ,					UpperCamelCase__				:   list[int]       ):


	"""simple docstring"""
	__UpperCAmelCase							=			[0] * no_of_processes
	for i in range(UpperCamelCase__       ):
		__UpperCAmelCase							=			burst_time[i] + waiting_time[i]
	return turn_around_time


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

					__lowerCAmelCase	:       List[Any]						       =	4
					__lowerCAmelCase	:       List[Any]						       =	[2, 5, 3, 7]
					__lowerCAmelCase	:       Tuple						       =	[0, 0, 0, 0]
					__lowerCAmelCase	:       Optional[int]						       =	calculate_waitingtime(arrival_time, burst_time, no_of_processes)
					__lowerCAmelCase	:       Dict						       =	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}""")
