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/17192
🧭 풀이 시간
18분

👀 체감 난이도
✏️ 문제 설명
N개의 뱀 그룹 각각에 뱀이 A[i]마리씩 있다.
그물의 사이즈를 정해서, 사이즈 이하의 연속된 그룹에 존재하는 뱀들을 잡을 수 있다.
이 때, 그룹에 존재하는 뱀들은 각각 그물의 사이즈 이하여야 한다.
한 번의 채집에 대한 wasted space란, (그물의 사이즈)*(그룹 수) - (뱀들의 수)이다.
처음에 그물의 사이즈는 마음대로 정할 수 있고, 최대 K번 사이즈를 바꿀 수 있을 때 wasted space의 합을 최소로 해보자.
🔍 풀이 방법
[사용한 알고리즘]
2차원 dp를 작성하고, 이를$O(N^3)$ 에 구현해서 해결했다.
dp[i][k] = i번째 그룹까지 잡았고, 그물 사이즈를 k번 바꿨을 때의 최솟값으로 정의했다.⏳ 회고
무난한 dp이다