Conversation
jjuchan
reviewed
Jul 15, 2025
| public static void main(String[] args) throws IOException { | ||
| BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
| StringBuilder sb = new StringBuilder(); | ||
|
|
Collaborator
There was a problem hiding this comment.
StringTokenizer 사용하면 공백 기준으로 토큰을 자동 분리할 수 있어서 split보다 메모리 사용량이 조금 더 효율적이고 속도도 약간 빠른 편이라고 알고 있습니다!!
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.
📌 문제 링크
백준 2240번 - 자두나무


📝 문제 개요
🧩 풀이 요약
이동 횟수(W)이 행, 시간(T)이 열인 2차원 배열 dp를 사용한다.
이동을 안한 경우 (w == 0)
현재 위치와 열매가 떨어지는 위치가 같다면 이전 시간의 같은 이동 횟수의 값 +1
위치가 다르면 이전 시간의 같은 이동 횟수의 값 그대로
이동을 하는 경우 (w >= 1)
현재 위치에 열매가 떨어지는 경우,
가만히 있는 경우: dp[w][t-1] + 1
움직인 경우: dp[w-1][t-1] + 1
위의 두 경우 중 더 큰 값을 dp[w][t]에 저장한다.
현재 위치와 열매가 떨어지지 않은 경우
가만히 있는 경우: dp[w-1][t]
움직인 경우: dp[w-1][t-1]
위의 두 경우 중 더 큰 값을 dp[w][t]에 저장한다.
😁 결과