개발자 톡

연습문제 톡 강의실 배정

강의실 배정문제 반례 찾아주시면 감사하겠습니다(python)

등록일
2024-02-08 15:45:28
조회수
317
작성자
harold10

import sys

input = sys.stdin.readline


n = int(input().strip())

time_list = []


for _ in range(n):

  time_list.append(list(map(int, input().split())))

   

time_list.sort(key=lambda x: (x[0], x[1]))


count = 0

end = 0

for t in time_list:

  if t[0] >= end:

    count += 1

    end = t[1]


print(count)


반례 찾아주시면 감사하겠습니다. 시간 초과는 아슬아슬하게 안쪽으로 들어오는데 로직에 어떤부분이 잘못되었는지 모르겠어요..

#강의실_배정
#python

이 카테고리의 톡 더보기