N = int(input()) A = [] for i in range (0,N): a = list(map(int,input().split())) A.append(a) def f(n): if n == 0: return A[0][0] else: for i in range (1,n): for j in range (0,len(A[i])): if j == 0: A[i][j] += A[i-1][j] elif j == len(A[i-1]): A[i][j] += A[i-1][j-1] else: a = A[i][j] + A[i-1][j-1] b = A[i][j] + A[i-1][j] A[i][j] = max(a,b) ans = max(A[n-1]) return ans print(f(N)) 먼저, 삼각형의 끝부분의 합에 ..