백준 11000 - 강의실 배정


백준 11000 - 강의실 배정

12345678910111213141516171819import sys,heapqn = int(sys.stdin.readline())times = []end = []for _ in range(n): s, t = map(int, sys.stdin.readline().split()) heapq.heappush(times,[s,t])times.sort() tmp = []heapq.heappush(tmp, times[0][1])for i in range(1,n): if tmp[0] > times[i][0]: heapq.heappush(tmp, times[i][1]) else: heapq.heappop(tmp) heapq.heappush(tmp,times[i][1]) print(len(tmp))Colored by Color Scriptercs tmp에 초기값으로 수업 종료 시간을 넣는다. 수업 종료 시간보다 시작 시간이 이른 값에 대해 종료시간을 tmp에 넣는다.시작 시간이 늦은 값이 나오면 비교하던 종료시간을 빼고 새로운 종료 시..........



원문링크 : 백준 11000 - 강의실 배정