[20251120] PGM / LV2 / 호텔 대실 / 강신지 #1462
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/155651
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
방 예약 시간이 (시작 시간, 종료 시간)으로 2차원 배열 형태로 주어질 때, 필요한 최소 객실 수를 구하는 문제.
이용 후 청소 시간이 있어 10분 후부터 새 손님 받을 수 있음.
🔍 풀이 방법
문자열(HH:MM)로 시간이 주어지기 때문에 시간과 분 모두 분에 맞춰 바꾸고 int 배열에 저장.
시작시간 오름차순으로 정렬해두고, 우선순위 큐 만들어서 각 예약의 종료 시간을 최소 힙으로 관리.
새 예약의 시작시간이 힙의 최소 종료시간보다 빠르면 새 방 추가, 느리면 기존 방 사용으로 처리하며 계산.
⏳ 회고
HHMM 이렇게 천의자리의 수로 변환하려다가 걍 싹 다 분 기준으로 맞춰버렸다. 어차피 00시부터 23시 59분까지만 주어지기 때문에 훨씬 편함.