def solution(fees, records):

    answer=[]

    

    

    time_dic = {} #각 차별로 얼마나 있었는지 기록할 딕셔너리

    

    

    #기록

    for record in records:

        raw = record.split()

        time = int(raw[0].split(':')[0])*60 + int(raw[0].split(':')[1])

        car = int(raw[1])

        if time_dic.get(car):

            if raw[2] == "OUT":

                time_dic[car] += time

            else:

                time_dic[car] -= time

        else:

            time_dic[car] = -time

            

            

    #안나왔으면 23:59에 나온걸로 찍음

    for car in time_dic:

        if time_dic[car] <=0:

            time_dic[car]+=1439

    

    

    

    #정렬해서 해답출력

    for car in sorted(time_dic):

        answer.append(cal_fee(fees,time_dic[car]))

    return answer




#시간별로 가격 계산해줄 함수

def cal_fee(fees,time):

    if time<fees[0]:

        return fees[1]

    else:

        return fees[1]-((fees[0]-time)//fees[2])*fees[3]





어디서 테스트케이스 에러가 난건지 모르겠네요