[20250712] BOJ / G2 / 할로윈의 양아치 / 이강현 #447
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/20303
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
할로윈에 일찍 자버려서 애들이 캔디 다 받아가서 빡침.
애들꺼를 다 뺏어버리기로 작정
한 아이의 캔디 뺏으면 그 애의 친구들도 다 뺏어버릴거임.
근데 K명 이상 뺏어버리면 공명이 일어나서 어른들이 잠에서 깨서 혼나
어른들 몰래 애들 캔디를 최대한 많이 뺏었을 때, 그 캔디의 수를 출력.
🔍 풀이 방법
BFS, DP, 배낭
배낭 문제 베이스에 친구 관계에 있는 애들거 다 뺏을 거니까 BFS 돌아서 한 아이 캔디 뺏을때
같이 뺏기는 친구들 수랑 총 캔디수를 저장해둠.
이걸로 dp 배열 채우기
⏳ 회고
처음에 정렬문제인 줄 알고 정렬 조건 생각하느라 시간을 너무 많이 씀.
K를 넘게 뺏으면 안된다는 점에서 배낭 문제 아이디어를 얻은듯