Skip to content

Commit f692d68

Browse files
committed
[BOJ] #1932. 정수삼각형 / 실버1 / 32분(성공)
1 parent 9a94062 commit f692d68

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
# 입력값 저장
5+
n = int(input())
6+
arr = []
7+
for i in range(n):
8+
temp = list(map(int, input().split()))
9+
arr.append(temp)
10+
11+
# DP 처리
12+
for i in range(1, n):
13+
for j in range(0, i+1):
14+
if j == 0:
15+
arr[i][j] += arr[i-1][j]
16+
elif j == i:
17+
arr[i][j] += arr[i-1][j-1]
18+
else:
19+
arr[i][j] += max(arr[i-1][j], arr[i-1][j-1])
20+
# 최대 합
21+
print(max(arr[n-1]))

0 commit comments

Comments
 (0)