[20250712] BOJ / G5 / 숏코딩의 왕 브실이 / 이종환#445
Merged
ShinHeeEul merged 1 commit intomainfrom Jul 12, 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/29726
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
위 식과 같은 계산을 통해 행복도를 구한다. 이때 수열에서 최대 m개의 숫자를 제거할 수 있을 때 최대 행복도를 구하자.
🔍 풀이 방법
처음에는 좀 당황했는데, 잘 생각해보니 결국 수열의 끝값 - 첫값 이다.
그렇기에 끝에서 몇번째에서 처음에서 몇번째를 뺼 지만 정하면 되는 것이었다.
물론 m개가 아니라 '최대 m개'이기에 단순하게 0~m개 제거 시 값을 일일히 계산하면 시간이 터진다.
그렇기에
minArrmaxArr이 두 개의 배열을 도입 한 후, 이를 통해 O(n)으로 계산하여 해결하였다.
⏳ 회고
풀이법을 알고나면 정말 쉬운문제