쏘ing
[Python] 백준 1931 회의실 배정 본문
https://www.acmicpc.net/problem/1931


풀이 1
num = int(input())
num_list = []
for _ in range (num):
a, b = map(int, input().split())
num_list.append([a, b])
# 끝나는 시간으로 정렬한 걸 기준으로 시작하는 시간으로 정렬
num_list.sort(key = lambda x: (x[1], x[0]))
temp = num_list[0][1]
count = 1
for i in range (1, num):
if num_list[i][0] >= temp:
count += 1
temp = num_list[i][1]
print(count)
풀이 2
num = int(input())
num_list = []
for _ in range (num):
a, b = map(int, input().split())
num_list.append([a, b])
# 시작하는 시간으로 정렬하고 끝나는 시간으로 정렬
num_list.sort(key = lambda x: (x[0]))
num_list.sort(key = lambda x: (x[1]))
temp = num_list[0][1]
count = 1
for i in range (1, num):
if num_list[i][0] >= temp:
count += 1
temp = num_list[i][1]
print(count)
'알고리즘 > CLASS 3' 카테고리의 다른 글
[Python] 백준 11659 구간 합 구하기 4 (0) | 2022.03.02 |
---|---|
[Python] 백준 1541 잃어버린 괄호 (0) | 2022.02.27 |
[Python] 백준 2606 바이러스 (0) | 2022.02.26 |
[Python] 백준 1260 DFS와 BFS (0) | 2022.02.26 |
[Python] 백준 11726 2 x n 타일링 (0) | 2022.02.26 |
Comments