Merged
Conversation
Minjeong / 3월 3주차 / 4문제
Hongjoo/ 3월 3주차 / 4문제
JYP / 3월 3주차 / 3문제
Collaborator
|
금주는 DP문제를 많이 푸셨군요. 잘하셨습니다. LGTM |
Collaborator
Author
|
LGTM을 처음 알게 되었네요!! 호홍 새롭게 배우네요 감사합니당~~
|
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.
목표 문제 수: 4개
아래는 제가 정리한 내용 중에서, 핵심이 되는 플로우와 TIL 위주를 가져왔습니다.
백준 #1904. 01타일: DP 실버3
정리한 노션 링크: 노션
이걸 어떻게 문제를 풀까 고민하다가, DP는 “점화식”이 가장 중요하다는게 떠올랐다.
점화식은 예제에 나온 값들 간의 “관계성”과 “규칙성”을 찾아야 한다. 따라서 그 부분에 대해 집중해서 보았다. 마치 규칙이 피보나치 수열처럼$A_i = A_{i-1} +A_{i-2}$ 처럼 되면 성립할 것처럼 보였다.
🚩플로우
🚩My submission
💡TIL
백준 #9461. 파도반수열 : DP, 실버3
정리한 노션 링크: 노션$P(N) = P(N-3)+P(N-2)$ 이다. 점화식에서 최소로 필요한 값인 P(N-3)을 만족하기 위해서는 반복문을 시작할 때의 값은 4부터 시작해야 하며, 이를 위해서는 P(1)~P(3) 까지는 미리 값이 1로 초기화되어 있어야 한다는 것을 알 수 있다
내가 찾은 점화식은
🚩플로우
T를 입력받는다.dp를 초기화한다. 문제에서 최대값이 100이고, 사용하는 값은 1부터 시작하므로 101사이즈로, 그리고 미리 설정해두어야 하는 P(1)~P(3)의 값이 1이므로[1] * 101로 초기화한다.T만큼 반복하며 테스트케이스 값,p_n을 입력받는다.dp를 시작하는 반복문을 넣는다. 이는 4부터p_n까지 반복하며, 위에서 세운 점화식dp[i] = dp[i-3]+dp[i-2]를 수행한다.🚩My submission
백준 #1912. 연속합: DP, 실버2
정리한 노션 링크: 노션
실패한 직관:
성공한 직관:
max()함수를 이용하여 누적된 값과, 현재 값을 비교하여 더 큰 값을dp테이블에 저장한다.🚩플로우
새로운 로직으로 다시 짰다. 이때의 키 포인트는 “지금까지 누적한 값과 현재값 중에서 더 큰 값으로 dp에 저장”한다는 것이다.
플로우는 아래와 같다. (위의 플로우와 바뀐 부분은 빨간색으로 표시했다.)
n, 수열:nums리스트, dp테이블:dp)”이전 dp값에 nums의 현재값을 더한 값인 누적값”과 “nums의 현재값” 중 더 큰 값을 dp에 저장한다.
🚩My submission
💡TIL
PGS 숫자의표현: 브루트포스, 레벨2
정리한 노션 링크: 노션
🚩플로우
🚩My submission