Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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://www.acmicpc.net/problem/31806
🧭 풀이 시간
80분
👀 체감 난이도
✏️ 문제 설명
준긋이는 구조대 대장이고, 담당 선생님께 허락받은 M시간 동안 연속으로만 활동할 수 있다. 시작 시각 s를 선택하면 s시 30분 ~ (s+M)시 30분까지 활동한다.각 팀은 고유 번호와 함께 활동 가능한 시간대들을 가지고 있다. 시간대는 [l, r) 형식으로 주어진다 (l시 00분 ~ r-1시 59분).
s를 적절히 선택해서 참여 가능한 팀의 수를 최대화하자.
🔍 풀이 방법
언제 상황이 바뀌는 지 체크한다.
interval [l, r)이 준긋이 활동시간 [s+0.5, s+M+0.5)와 겹치는 조건:
s+0.5 < r AND l < s+M+0.5
→ s < r AND s > l-M
→ l-M < s < r
즉, interval은 s = l-M일 때 활성화되고, s = r일 때 비활성화된다.
s가 변하는 부분만 체크해서 처리한다.
⏳ 회고
문제를 이해하는 게 어려웠고, 스위핑 알고리즘이 익숙하지않아 너무 어려웠다. 변화하는 시점만을 체크하는 법을 고민해야겠다.