[20250626] BOJ / P4 / 마이마이 순회 돌기 / 권혁준 #390
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://www.acmicpc.net/problem/34039
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
N개의 수록곡 각각의 시간은 A[i]이다.
세 종류의 쿼리를 처리해보자.
🔍 풀이 방법
카운팅 배열을 떠올리면 된다.
세그먼트 트리의 말단 노드에는 해당 수가 몇 개 들어있는지 + 그 수의 합을 저장해놓는다.
2번 쿼리에서 곡의 최대 개수를 구할 때는 재귀적으로 시간이 작은 곡부터 처리하는 방식으로 구할 수 있다.
⏳ 회고
구현이 은근 헷갈림 + 시간이 같은 곡이 여러 개 있는 경우의 처리가 생각보다 쉽지 않음