def solution(fees, records):
answer = []
parking = {}
minute = {}
for record in records:
time, car, action = record.split()
if car not in minute:
minute[car] = 0
for record in records:
time, car, action = record.split()
time = int(time[:2]) * 60 + int(time[3:5])
if action == 'IN':
parking[car] = time
else:
minute[car] += time - parking[car]
del parking[car]
for car, time in parking.items():
minute[car] += (23 * 60 + 59) - time
cars = sorted(minute.keys())
for car in cars:
total_time = minute[car]
if total_time <= fees[0]:
fee = fees[1]
else:
fee = fees[1] + ((total_time - fees[0] + fees[2] - 1) // fees[2]) * fees[3]
answer.append(fee)
return answer
PREVIOUS[백준] 색종이 만들기