본문 바로가기
알고리즘/백준

[Python] 백준 1931번: 회의실 배정

by 말랭쓰 2021. 7. 3.
320x100

문제

https://www.acmicpc.net/problem/1931

 

1931번: 회의실 배정

(1,4), (5,7), (8,11), (12,14) 를 이용할 수 있다.

www.acmicpc.net

풀이

import sys
N = int(sys.stdin.readline())
L=[]
for _ in range(N):
    L.append(list(map(int,sys.stdin.readline().split())))
L.sort(key=lambda x: (x[1],x[0]))

end=0
count=0
for i in range(N):
    if end <= L[i][0]:
        end = L[i][1]
        count += 1
print(count)
300x250
반응형

댓글