[20250829] BOJ / G1 / 공평하게 팀 나누기 / 한종욱 #767
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/4384
🧭 풀이 시간
70분
👀 체감 난이도
✏️ 문제 설명
N명이 있는데 인원 차이는 1명차이나 0명차이에 각 그룹의 합의 차가 최소가 되는 방법
🔍 풀이 방법
Set dp를 사용했다. [모든 몸무게의 합/2]보다 같거나 작은 몸무게만 dp에 담으며, 중복이 되면 안되므로 역순으로 계산했다.
작은 몸무게가 dp[dp.length-1]에 있거나 N이 홀수일 경우 dp[dp.length-2]에 있을 수도 있어서 둘 다 체크했다.
⏳ 회고
준희는 boolean dp로 풀었고 그게 정석풀이 같다. 더 빠르고 더 효율적이다. 그 방법으로 주말에 풀어봐야겠다. 하지만, dp의 상태를 정의해 접근해서 뿌듯하다.