Skip to content

Commit 0c74807

Browse files
committed
[BOJ] #1931. 회의실 배정 / 골드5 / 30분 / 성공
1 parent f14f883 commit 0c74807

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
# 입력
5+
N = int(input())
6+
meetings = [[0, 0] for _ in range(N)]
7+
8+
for i in range(N):
9+
start, end = map(int, input().split())
10+
meetings[i][0] = start
11+
meetings[i][1] = end
12+
13+
# 끝나는 시간을 기준으로 정렬, 끝나는 시간이 같으면 시작 시간을 기준으로 정렬
14+
meetings.sort(key=lambda x: (x[1], x[0]))
15+
16+
cnt = 0 # 회의 개수
17+
last_end_time = 0 # 마지막으로 배정된 회의의 종료 시간
18+
19+
for start, end in meetings:
20+
if start >= last_end_time: # 현재 회의 시작 시간이 마지막 회의 종료 시간 이후라면
21+
cnt += 1 # 회의 배정
22+
last_end_time = end # 회의 종료 시간 업데이트
23+
24+
print(cnt)

0 commit comments

Comments
 (0)