[20250310] BOJ / G1 / Balanced Lineup / 신희을 #220
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/6213
🧭 풀이 시간
30 분
👀 체감 난이도
✏️ 문제 설명
매일 젖을 짜기 위해 Farmer John의 N마리의 소(1 <= N <= 50,000)는 항상 같은 순서로 줄을 서 있습니다. 어느 날 Farmer John은 일부 소와 함께 얼티밋 프리즈비 게임을 하기로 합니다. 간단하게 하기 위해 그는 젖을 짜는 줄에서 인접한 소들을 데려와 게임을 합니다. 그러나 모든 소가 재미있게 놀려면 키가 너무 다르지 않아야 합니다.
농부 존은 Q(1 <= Q <= 180,000)개의 잠재적인 소 그룹과 그들의 키(1 <= 키 <= 1,000,000) 목록을 만들었습니다. 그는 각 그룹에서 가장 작은 소와 가장 큰 소의 키 차이를 알아내는 데 도움을 원합니다.
🔍 풀이 방법
기본 세그먼트 트리, 최대 세그 트리와 최소 세그 트리를 두고 조회를 한다. 혹은 클래스를 활용해 세그 트리 한 개로 구현할 수도 있다.
⏳ 회고
오랜만에 기본 세그 트리 문제 풀었다.