# Baekjoon-11049-행렬 곱셈 순서

30 Sep 2022PyPy3 로 제출해야함!!

```
import sys
input = sys.stdin.readline
N = int(input())
mats = []
for _ in range(N):
r,c = map(int,input().split())
mats.append([r,c])
infty = int(2**31-1)
dp = [[infty] * N for _ in range(N)]
for i in range(N):
dp[i][i] = 0
for j in range(N):
for i in reversed(range(j)):
for k in range(i,j):
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + mats[i][0]*mats[k][1]*mats[j][1])
print(dp[0][N-1])
```