[20250705] BOJ / G4 / 호텔 / 설진영 #417
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/1106
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
호텔 사장이 홍보를 통해 최소 C명의 고객을 늘리려고 함.
각 도시마다 홍보 비용과 증가하는 고객 수가 주어지고, 각 도시에서 무제한으로 홍보 가능(정수배만).
목표 고객 수 이상을 달성하는 최소 비용을 구하는 문제.
🔍 풀이 방법
Unbounded Knapsack Problem(무한 배낭 문제)
dp[i] = 정확히 i명의 고객을 얻는 최소 비용
각 도시에 대해 무제한으로 선택 가능하므로 내부 반복문에서 앞에서부터 업데이트
목표보다 많은 고객을 얻을 수 있으므로 배열 크기를 C + 101로 설정
최종적으로 dp[C]부터 dp[C+100] 중 최솟값이 답
dp[j] = min(dp[j], dp[j - customer[i]] + cost[i])
⏳ 회고
목표 고객 수를 "이상"으로 해석하는 부분에서 배열 크기 설정 중요