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())
cnt = 1
time = []
for i in range(n):
time.append( list(map(int, sys.stdin.readline().split())) )
time.sort(key= lambda x : (x[1],x[0]))
tm = time[0][1]
for i in range(1,n):
if tm <= time[i][0]:
cnt += 1
tm = time[i][1]
print(cnt)
time list를 끝, 시작 순서의 중요도로 오름차순 정리
이후 끝이 다음 시작보다 크면 넘어가고 아니면 cnt++
'2022 하반기 > Python' 카테고리의 다른 글
백준 10815 python (0) | 2023.02.17 |
---|---|
Characteristics of python data type(파이썬 데이터 타입의 특성) (0) | 2023.02.16 |
백준 11047 Python (0) | 2023.02.07 |
백준 2750 Python (0) | 2023.02.07 |
백준 1436 Python (0) | 2023.02.07 |
댓글