From a1869b864d1cac40d295dd462b0c85d7c120f12b Mon Sep 17 00:00:00 2001 From: SSUM <116950962+ssum21@users.noreply.github.com> Date: Thu, 3 Apr 2025 14:39:35 +0900 Subject: [PATCH] =?UTF-8?q?[Gold=20V]=20Title:=20=EA=B0=95=EC=9D=98?= =?UTF-8?q?=EC=8B=A4=20=EB=B0=B0=EC=A0=95,=20Time:=20300=20ms,=20Memory:?= =?UTF-8?q?=2062456=20KB=20-BaekjoonHub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 백준/Gold/11000. 강의실 배정/README.md | 36 +++++++++++++++++++++ 백준/Gold/11000. 강의실 배정/강의실 배정.py | 26 +++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 백준/Gold/11000. 강의실 배정/README.md create mode 100644 백준/Gold/11000. 강의실 배정/강의실 배정.py diff --git a/백준/Gold/11000. 강의실 배정/README.md b/백준/Gold/11000. 강의실 배정/README.md new file mode 100644 index 0000000..9619118 --- /dev/null +++ b/백준/Gold/11000. 강의실 배정/README.md @@ -0,0 +1,36 @@ +# [Gold V] 강의실 배정 - 11000 + +[문제 링크](https://www.acmicpc.net/problem/11000) + +### 성능 요약 + +메모리: 62456 KB, 시간: 300 ms + +### 분류 + +자료 구조, 그리디 알고리즘, 우선순위 큐, 정렬 + +### 제출 일자 + +2025년 4월 3일 14:39:21 + +### 문제 설명 + +

수강신청의 마스터 김종혜 선생님에게 새로운 과제가 주어졌다.

+ +

김종혜 선생님한테는 Si에 시작해서 Ti에 끝나는 N개의 수업이 주어지는데, 최소의 강의실을 사용해서 모든 수업을 가능하게 해야 한다.

+ +

참고로, 수업이 끝난 직후에 다음 수업을 시작할 수 있다. (즉, Ti ≤ Sj 일 경우 i 수업과 j 수업은 같이 들을 수 있다.)

+ +

수강신청 대충한 게 찔리면, 선생님을 도와드리자!

+ +### 입력 + +

첫 번째 줄에 N이 주어진다. (1 ≤ N ≤ 200,000)

+ +

이후 N개의 줄에 Si, Ti가 주어진다. (0 ≤ Si < Ti ≤ 109)

+ +### 출력 + +

강의실의 개수를 출력하라.

+ diff --git a/백준/Gold/11000. 강의실 배정/강의실 배정.py b/백준/Gold/11000. 강의실 배정/강의실 배정.py new file mode 100644 index 0000000..6b6e858 --- /dev/null +++ b/백준/Gold/11000. 강의실 배정/강의실 배정.py @@ -0,0 +1,26 @@ +import sys +import heapq + +input = sys.stdin.readline + +n = int(input()) + +table = [] + +for _ in range(n): + start, end = map(int, input().split()) + table.append((start, end)) + +table.sort() + +rooms = [] + +heapq.heappush(rooms, table[0][1]) + +for i in range(1, n): + if table[i][0] >= rooms[0]: + heapq.heappop(rooms) + + heapq.heappush(rooms, table[i][1]) + +print(len(rooms)) \ No newline at end of file