Skip to content

Conversation

@Seol-JY
Copy link
Contributor

@Seol-JY Seol-JY commented Jul 16, 2025

🧷 문제 링크

https://www.acmicpc.net/problem/19942

🧭 풀이 시간

25분

👀 체감 난이도

✏️ 문제 설명

N개의 식재료 중 일부를 선택해서 단백질, 지방, 탄수화물, 비타민의 최소 조건을 만족하면서 비용을 최소화하는 문제. 같은 비용이면 사전순으로 가장 빠른 조합을 출력해야 함.

🔍 풀이 방법

백트래킹으로 해결함. 선택 / 선택X 의 2가지 경우를 모두 탐색하되 가지치기로 최적화
조건 만족하면 즉시 종료
비용 초과하면 가지치기로 중단

처음에는 비트마스킹으로 풀었는데 사전순 처리가 복잡해서 백트래킹으로 변경함.

⏳ 회고

N≤15라서 완탐문제 같긴 했음
비트마스킹으로 풀려 했는데 백트래킹이 훨씬 깔끔하고 빠름

image

@Seol-JY Seol-JY added the success 👍 해설을 보지 않고 풀었을 때 label Jul 16, 2025
@ShinHeeEul ShinHeeEul merged commit 43db0e3 into main Jul 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

success 👍 해설을 보지 않고 풀었을 때

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants