[20251002] BOJ / G4 / 사탕가게 / 이준희 #1020
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/4781
🧭 풀이 시간
50분
👀 체감 난이도
✏️ 문제 설명
상근이가 가지고 있는 돈과
사탕의 칼로리, 사탕 가격이 주어졌을 때
상근이가 살 수 있는 사탕의 가장 칼로리가 높은 경우를 구하는 문제입니다.
🔍 풀이 방법
DP를 이용해 풀었습니다.
상근이의 지갑 사정과 사탕의 가격이 소수점 2자릿수까지 나타나기 때문에
100을 곱해서 정수로 변환하여 풀었습니다.
⏳ 회고
부동 소수점 때문에 100 곱해서 정수 변환 시 0.5를 더해서 해야
234.50 이 실제로 234.49999997 인 경우 같은 것을 해결할 수 있었는데
검색해서 알아보지 않았으면 평생 못풀었습니다.