[20260305] BOJ / D5 / 제설 작업 / 권혁준#1993
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 4, 2026
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/34757
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
N개의 지점이 1번부터 N번까지 일렬로 나열되어 있고, 각 지점에는 S[i] 만큼의 눈이 쌓여있다.
제설 작업이 총 M번 진행되며, i번째 작업은 다음 과정으로 이루어진다.
작업들은 순차적으로 이루어진다.
Q개의 질문을 처리해보자. 각 질문은 세 정수 A, B, T로 이루어진다.
🔍 풀이 방법
쿼리를 하나만 처리한다고 생각하면, 쿼리를 결정 문제로 변환하고 이분 탐색으로 풀 수 있다.
-> 여러 개의 쿼리를 처리해야 하니까 병렬 이분 탐색을 사용한다.
쿼리마다 이분 탐색의 범위 lo[i], hi[i]를 관리하고, 작업을 1번부터 M번까지 쭉 수행하며 mid[i]번째 작업이 끝난 직후 해당 쿼리에 대한 결정 문제를 풀어 탐색 범위를 조절한다.
여기서 결정 문제는
작업을 mid[i]번째까지 진행했을 때 구간 [A, B]에서 치운 눈의 양이 T 이상인가?로 두었다.-> 이분 탐색의 성질에 따라 탐색 범위가 조절되는 총 횟수는 O(logM)이 된다.
작업을 naive하게 처리하면 O(MN)이라서 분리 집합으로 최적화하여 O(MlogN)으로 만들어준다.
구간 합도 관리해야 하기 때문에 세그먼트 트리를 사용했다.
⏳ 회고
병렬 이분 탐색을 깨달아버렸다