Merged
Conversation
Contributor
|
ㄸㄸㄸㄸㄸㄸㄷ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AZZ_XjxKgVLHBINj&categoryId=AZZ_XjxKgVLHBINj&categoryType=CODE&problemTitle=24396&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1
🧭 풀이 시간
10분
👀 체감 난이도
✏️ 문제 설명
B개의 검은 공, W개의 흰 공, B개의 검은 상자, W개의 흰 상자가 있다.
당신은 모든 공을 상자에 담아서, 모든 상자가 정확히 한 개의 공을 담고 있도록 하고자 한다.
모든 공을 상자에 넣으면, 아래와 같이 각 상자마다 점수를 계산한다.
검은 상자에 검은 공이 들어 있으면 X점, 흰 상자에 흰 공이 들어 있으면 Y점, 검은 상자에 흰 공이 들어 있거나 흰 상자에 검은 공이 들어 있으면 Z점이다.
당신은 모든 상자의 점수의 합이 최대화되도록 공을 넣고자 한다. 이 때 얻을 수 있는 최대 점수를 구하는 프로그램을 작성하라.
🔍 풀이 방법
[사용한 알고리즘]
검은 공 c개를 흰색 상자에 넣는다면, 흰 공 c개도 반드시 검은 색 상자로 와야 한다.$2cZ + X(B-c) + Y(W-c)$ 이다.
이를 가지고 점수 구하는 식을 세우면,
c를 완탐으로 돌려서 최대 점수를 구하면 된다.
⏳ 회고
진영's pick 문제 재밌었다