백준 1931번: 회의실 배정 #Python

ColorlessDia·2025년 6월 3일

algorithm/baekjoon

목록 보기
562/807
import sys

input = sys.stdin.readline

N = int(input())

schedule_list = [list(map(int, input().split())) for _ in range(N)]
schedule_list.sort(key=lambda x: (x[1], x[0]))

before_schedule = schedule_list[0]
count = 1

if N == 1:
    print(count)
else:
    
    for current_schedule in schedule_list[1:]:
        before_end = before_schedule[1]
        current_start = current_schedule[0]

        if before_end <= current_start:
            before_schedule = current_schedule
            count += 1
    
    print(count)

0개의 댓글