[20251123] BOJ / G5 / 용액 / 강신지 #1487
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/2467
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
특성을 정수로 나타내는 용액들이 있다.
두 개의 서로 다른 용액을 혼합하여 특성값이 0에 가장 가까운 용액을 만들어내라
🔍 풀이 방법
투포인터로 풀었습니다.
두 용액 문제와 달리 이번 '용액' 문제는 배열이 이미 정렬된 상태로 주어지기 때문에 그냥 바로 l, r 잡고 계산하면 됩니다.
bestSum과 새 sum의 절댓값을 비교하며 best 값을 갱신하고 sum 값을 0과 비교하여 적절히 l, r을 조절합니다.
⏳ 회고
두 용액 문제는 여기서 배열 정렬하는 코드만 추가하면 되더군요