[20251025] PGM / LV4 / 징검다리 / 강신지 #1226
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/43236
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
출발점과 도착점 사이 거리 distance와 그 사이에 있는 돌들의 위치 배열이 주어짐. 돌들 중 n개를 제거한다고 할 때, 각 구간 거리의 최솟값이 최대가 되도록 해라
🔍 풀이 방법
이분탐색을 썼다.
출발점부터 돌을 보면서, 직전에 남겨둔 지점과의 거리가 mid보다 작은 돌은 제거하고, mid 이상 떨어져 있다면 직전 지점을 그 돌로 갱신한다. 마지막으로 도착점까지의 거리도 검사해서 제거한 돌의 수를 센다.
제거 수와 n을 비교하여 이분탐색으로 가능한 최대 mid를 찾는다.
⏳ 회고
통나무보단 쉽다