[20251029] BOJ / P1 / 쉽게 제한된 메모리 / 권혁준#1265
Merged
ShinHeeEul merged 1 commit intomainfrom Oct 29, 2025
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/12926
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
배열 X는 다음과 같이 생성된다.
X[0] = 0, X[i] = (X[i-1] * a + b) % 1,000,000,007
X[0]부터 X[N-1]까지 N개의 정수로 구성된 배열 X에 다음 쿼리를 Q개 처리해보자.
N <= 1,000,000
Q <= 100
🔍 풀이 방법
메모리 제한이 너무 작아서 배열 X를 선언할 수 없다.
f(n) = 배열 X에서 n보다 작은 수의 개수로 두고, 각 쿼리마다 파라메트릭 서치로 바꿔 생각했다.매 쿼리마다 각각 파라메트릭 서치를 돌리면 O(NQlogMOD)라 시간초과가 나서 f(n)을 구할 때 n이 겹치는 쿼리들에 대해선 한 번만 돌리도록 구현했다.
X를 순회하는 작업을 총 logMOD 번만 하고, 각 순회에서 쿼리들의 mid값을 정렬 후 잘 카운팅해줘서 모든 쿼리의 범위를 한 번에 줄여줬다.
⏳ 회고
이걸
병렬 이분 탐색이라 한다고 함.결정 문제를 한 번 푸는 과정에서 모든 쿼리에 대해 한 번 씩 해결하는 방법을 찾는 것이 핵심인 듯하다.
이걸 놓쳐서 시간초과가 났다