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.
📖 풀이한 문제
💡 문제에서 사용된 알고리즘
📜 코드 설명
plan이라는 이차원 배열에
p[i][0]: i날의 상담에 걸리는 시간, p[i][1]: i날의 상담 후 받을 수 있는 금액을 넣어줬다.
T: 상담 시간, P: 상담 금액
D[i]: i날까지의 최대 수익
N+1일에 퇴사하므로 int D []=D [n+2]로 초기화해줌.
-> 퇴사하는 N+1을 신경 써줘야 한다!( 마지막 날인 N인 날 하루 상담이었을 때를 위해서)
D [i+T] i+T날의 최대수익과 i날 상담을 들었을 때 받을 수 있는 수익 D [i]+P를 비교해서 큰 값 넣어준다.
D [i+T] i+T날의 최대수익과 D [i] i날까지의 최대 수익을 비교해서 큰 값을 넣어준다.
위의 점화식을 아래 반복문에서 돌려준다.
1일부터 N일까지 반복문을 돌며( i날에 상담을 들었을 때 i + T가 퇴사날짜 전에(<N+1))
close #65