the following implementation assumes that the activities are already sorted according to their finish time n total number of activities start an array that contains start time of all activities finish an array that contains finish time of all activities start 1 3 0 5 8 5 finish 2 4 6 7 9 9 printmaxactivitiesstart finish the following activities are selected 0 1 3 4 the first activity is always selected consider rest of the activities if this activity has start time greater than or equal to the finish time of previously selected activity then select it prints a maximum set of activities that can be done by a single person one at a time n total number of activities start an array that contains start time of all activities finish an array that contains finish time of all activities start 1 3 0 5 8 5 finish 2 4 6 7 9 9 print_max_activities start finish the following activities are selected 0 1 3 4 the first activity is always selected consider rest of the activities if this activity has start time greater than or equal to the finish time of previously selected activity then select it
def print_max_activities(start: list[int], finish: list[int]) -> None:
    
    n = len(finish)
    print("The following activities are selected:")

    
    i = 0
    print(i, end=",")

    
    for j in range(n):
        
        
        
        if start[j] >= finish[i]:
            print(j, end=",")
            i = j


if __name__ == "__main__":
    import doctest

    doctest.testmod()

    start = [1, 3, 0, 5, 8, 5]
    finish = [2, 4, 6, 7, 9, 9]
    print_max_activities(start, finish)