[20251020] PGM / LV2 / 땅따먹기 / 강신지 #1177
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://school.programmers.co.kr/learn/courses/30/lessons/12913
🧭 풀이 시간
15분
👀 체감 난이도
✏️ 문제 설명
N행 4열로 이루어진 땅을 1행부터 N행까지 각 행의 한 칸씩 밟으며 내려올 얻을 수 있는 점수의 최대값 구하기
단, 한 행씩 내려올 때, 같은 열을 연속해서 밟을 수 없는 특수 규칙이 있다.
🔍 풀이 방법
DP를 이용해 각 행의 각 열에 도달할 수 있는 최대 점수를 저장했다.
이전 행에서 같은 열을 제외한 세 열 중 최댓값을 더해가며 누적하고, 마지막 행의 최댓값을 반환한다.
⏳ 회고
이전 행의 값을 덮어쓰면 이후 계산에서 오류가 생기므로 임시 변수를 만들어 처리했다.
단순한 DP 문제라 어렵지 않았다.