[20250507] BOJ / D5 / Strike Zone / 신희을#326
Merged
ShinHeeEul merged 1 commit intomainfrom May 7, 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/17975
🧭 풀이 시간
120+ 분
👀 체감 난이도
✏️ 문제 설명
이 문제에서는 두 점 집합 P1(스트라이크)과 P2(볼), 그리고 상수 c1, c2가 주어집니다.
축에 평행한 직사각형 R을 정의할 때, eval(R) = c1 × s - c2 × b (R 안의 P1 점 개수는 보상, P2 점 개수는 벌점)를 최대화하는 R을 찾아야 합니다.
즉, 가능한 많은 스트라이크를 포함하고 가능한 적은 볼을 포함하는 최적의 스트라이크 존을 구하는 문제입니다.
🔍 풀이 방법
기본 금광 세그 문제다.
x좌표를 기준으로 정렬 후, 세그먼트 트리 리프 노드의 인덱스를 매긴다. (x좌표가 같다면 같은 인덱스를 부여한다)
다시 y좌표 기준으로 정렬 후,
바닥부터 꼭대기까지 올라가면서 update 한 후, 전 범위 연속합 최대를 구해주고
바닥을 제외한 y좌표부터 꼭대기까지 올라가면서 update 한 후, 전 범위 연속합 최대를 구해주고
다시 그 다음 y좌표부터 꼭대기까지 올라가면서 update 한 후, 전 범위 연속합 최대를 구해주고...
이 모든 값의 max를 구하면 정답!
(연속합 최대를 구할 때는 금광 세그먼트 트릭을 활용해 연속합을 구한다.)
⏳ 회고
비트 단위 입력으로 받으니 안되고, BufferedReader로 입력받으니까 통과되더라. 테스트 케이스에 탭이 섞여있나보다.