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/15732
🧭 풀이 시간
10분
👀 체감 난이도
✏️ 문제 설명
N개의 상자가 있고, 도토리를 상자에 넣는 규칙이 K개 주어진다.
각 규칙은 (A,B,C)로 구성되며, A번 상자부터 B번 상자까지 C의 간격으로 도토리를 하나씩 넣는 것을 의미한다.
규칙에 맞게 도토리를 모두 넣었을 때, 앞에서부터 D번째 도토리가 존재하는 상자의 번호를 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
상자의 번호를 매개 변수로 잡고, 이분 탐색으로 상자 번호를 찾아준다.
x번째 상자 이하에 몇 개의 도토리가 들어갔는지를 구해서, 이 값을 기준으로 이분 탐색의 범위를 조절해준다.
⏳ 회고
공식으로 풀었다.
"이걸 도대체 어떻게 풀지?" -> 90% 확률로 매개 변수 탐색이다.