[20260307] BOJ / G5 / 극장 좌석 / 이준희#2000
Merged
ShinHeeEul merged 1 commit intomainfrom Mar 7, 2026
Merged
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/2302
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
극장 좌석은 기본적으로 자기 자리에 앉아야 하지만 좌석번호 기준 +-1 번호에 앉는 것도 가능합니다.
그러나 vip 손님의 경우에는 무조건 본인 자리에만 앉습니다.
좌석 길이와 vip 좌석이 주어졌을 때 좌석에 앉을 수 있는 경우의 수를 구하는 문제입니다.
🔍 풀이 방법
dp를 이용해서 풀었습니다.
좌석번호 기준 +-1 까지만 앉을 수 있기 때문에 기본적으로는 구간의 경우의 수가 dp[n] = dp[n-1] + dp[n-2]가 됩니다.
이 때 vip 좌석은 교환이 안되는 벽과 같은 느낌으로 vip 좌석으로 끊어서 각각의 경우의 수끼리 곱했습니다.
⏳ 회고
어제 풀었던 것과 비슷한 방식의 dp였던 것 같습니다.