STUDY/Algorithm

[프로그래머스] LEVEL3 추석 트래픽, python3, 2018 KAKAO BLIND RECRUITMENT[1차]

sinawi95 2020. 1. 9. 07:11
728x90

def solution(lines):
    answer,len_lines,count = 0, 0 ,1
    start,finish=[],[]
    for log in lines:
        len_lines+=1
        #print("완료시간:",log[11:23],"처리시간:",log[23:-1],"s")
        tmp=float(log[11:13])*3600+float(log[14:16])*60+float(log[17:23])
        finish.append(tmp)
        start.append(round(tmp-float(log[24:-1])+0.001,3))
   # print("start:",start,"\nfinish:",finish)
    
    for i in range(len_lines):
        # 종료시간으로 오름차순 정렬이므로, 종료시간만 비교
        # 한 로그의 종료시간부터 1초 동안의 처리량을 확인, finish[i]+1 > start[j]
        count=1     # 초기화
        for j in range(i+1,len_lines):
            if (finish[i]+1>start[j]):
                count+=1
        if answer            answer=count
    return answer