[PGS] 땅따먹기 - #58
Open
been12151 wants to merge 10 commits into
Hidden character warning
The head ref may contain hidden characters: "week3/\ub545\ub530\uba39\uae30"
Open
Conversation
Collaborator
|
다음줄 같은열에 접근할 수 없으니까 그 열은 제외하고 리스트를 만드는 방법이 있군요! |
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.
🍪 문제 이름
Resolve: 땅따먹기
🍊 문제 정의
inputland: N행 4열로 이루어진 2차원 배열. 각 칸에는 점수가 쓰여 있음 (N은 100,000 이하의 자연수, 점수는 100 이하의 자연수)output예시
🍑 알고리즘 설계
DP로 풀이.
land[i][j]에 이전 행에서 j열을 제외한 나머지 3칸의 최댓값을 누적해서 더해감.land[i-1][:j] + land[i-1][j+1:]로 j열을 제외한 슬라이싱을 만들고, 그 중max()를 현재 칸에 더함.마지막 행까지 누적이 완료되면
max(land[-1])로 최댓값을 반환.🥝 최악 수행 시간 복잡도
O(n)(n = land의 행 수)🍰 특이 사항 (Optional)
land[i-1][:j] + land[i-1][j+1:]로 리스트 슬라이싱을 활용해 j열을 제외하는 부분으로 했는데, 열이 늘어나면 문제가 생길수도...