[20250320] BOJ / G1 / Lottery for Vitcoins at Moloco (Hard) / 권혁준#276
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 20, 2025
Merged
[20250320] BOJ / G1 / Lottery for Vitcoins at Moloco (Hard) / 권혁준#276ShinHeeEul merged 1 commit intomainfrom
ShinHeeEul merged 1 commit intomainfrom
Conversation
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://www.acmicpc.net/problem/15513
🧭 풀이 시간
36분

👀 체감 난이도
✏️ 문제 설명
상이 N개 준비되어 있다.
i번째 상을 얻으려면, 티켓을 한 장 낸 후 p[i]의 확률로 앞면이 나오는 동전을 던져서 앞면이 나와야 하고, 이 때 w[i]만큼의 코인을 얻는다. (만약 뒷면이 나온다면, 티켓은 사라진다.)
처음에 티켓 한 장이 있을 때, 상을 고르는 순서를 잘 정해서 얻는 코인의 기댓값을 최대로 해보자.
🔍 풀이 방법
[사용한 알고리즘]
어떤 임의의 두 상 (a, b)에 대해, 어떤 상이 먼저 와야 얻을 수 있는 코인의 기댓값이 높아지는지 생각해보면 된다.
a가 먼저 때의 기댓값과, b가 먼저 왔을 때의 기댓값을 각각 구해서 비교하면 된다. ( = exchange argument)
기댓값의 선형성에 의해, 전체 기댓값을 구할 필요 없이 a와 b가 관여하는 부분만 구해줘도 무관하다.
구한 값을 가지고 sort의 반환 조건을 정해주면 된다.
⏳ 회고
식 세우는 게 어려웠고 기댓값 중 a, b가 관여하는 부분만 구해도 된다는 건 증명이 안돼서 그냥 감으로 했다..