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]
테스트 케이스 하나가 틀리더라
올림 조건 있엇음
올림 계산했는데? 한번 더 확인해봄
def cal_free(fees, time): 바로 아래에 time<=fees[0]이였을껄? 추가요금 조건은 '초과 시' 였던걸로 기억하는데
근데 둘이 같으면 어짜피 else문에 뒤에 0이라서 똑같을거라고 생각함
아 그렇네 근데 왜 else에 빼기임? 기본요금에 더하긴데
a//b 이거 내림 대신 -(-a//b) 써서 올리함 보면 fees랑 time도 빼기 반대로함
파이써닉하구만...