def solution(lines):
answer = 0
trafics = []
for l in lines:
elements = l.split()
S = elements[1].split(':')
s = int((int(S[0]) * 3600 * 1000) + (int(S[1]) * 60 * 1000) + (float(S[2]) * 1000))
t = int(float(elements[2][:-1]) * 1000)
start = (s - t) + 1
end = s
trafics.append((start, end))
for trafic in trafics:
count = 0
for tr in trafics:
if tr[1] >= trafic[1] and tr[0] < trafic[1] + 1000:
count += 1
answer = max(count, answer)
return answer
아 문자열 다 정렬시키고 했는데
트래픽 조절도 알고리즘까지 생각해냈는데 for문으로 옮기는게 어려움;;
진짜 별찍기부터 다시해야하나 집중력이 안된건가
for trafic in trafics:
count = 0
for tr in trafics:
if tr[1] >= trafic[1] and tr[0] < trafic[1] + 1000:
count += 1
answer = max(count, answer)
return answer
이 부분 짜려고 한참 헤맸음 ;;
음 ..
'Programing > 자료구조, Algorithm' 카테고리의 다른 글
바이너리 서치 python (binary search python) (0) | 2022.04.15 |
---|---|
programmers -프렌즈4블록- (python) (0) | 2022.03.14 |
프로그래머스(programmers) 신고 결과 받기 -python- (0) | 2022.03.10 |
백준 1700 반례 (python) (0) | 2022.02.17 |
백준 1062 (python) (0) | 2022.02.16 |