[20250724] BOJ / G3 / 이진 트리 / 이종환 #538
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/13325
🧭 풀이 시간
80분
👀 체감 난이도
✏️ 문제 설명
포화이진트리에 들어 있는 모든 에지들의 가중치가 주어졌을 때, 어떤 에지들의 가중치를 증가시켜서 루트에서 모든 리프까지의 거리가 같게 하면서 에지 가중치들의 총합이 최소가 되도록 하는 프로그램을 작성하시오
🔍 풀이 방법
처음부터 리프노트부터 특정 노드 까지의 가중치의 합을 저장하는 array를 재귀를 통해 만들었다.
그러나 이후 계속해서 빡구현으로 풀려고 했으나, 헛다리만 짚다가 우연히 문제 태그에 DP가 있는 걸 보고, 바로 역으로 루트노드부터 리프노드까지 진행하면서의 가중치의 합을 저장하는 array를 만들어서 해결하였다.
⏳ 회고
트리를 오랜만에 보니까 헷갈린다.. 내일도 비슷한거 풀어야지...