[20250614] BOJ / G3 / 행렬 곱셈 순서 / 이강현 #352
Merged
+40
−0
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://www.acmicpc.net/problem/11049
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
행렬 곱셈은 연산 순서에 따라 그 연산 횟수가 달라짐. 이전 행렬의 열의 수와 이후 행렬의 행의 수는 맞추어져 있고 어느 부분을 먼저 연산할지를 결정해야함. 이때 최소 연산 횟수를 구하기.
🔍 풀이 방법
dp[i][j] : i부터 j까지의 최소 연산 횟수
구간을 2부터 N까지 늘려가며 시작점 끝점을 정의하고 반복문 내에서 분할지점마다 dp 배열을 업데이트함.
⏳ 회고
식에서 연산 순서를 조절하여 최대 혹은 최소값을 구하는 문제의 대표적인 유형인듯 싶다. 프로그래머스에서 괄호 치는 부분을 적절히 조정하는 사칙연산 문제랑 비슷했다.