▶ 코드

 

n = int(input())
p = []

for i in range(n):
    p.append(list(map(int, input().split())))

for i in range(1, len(p)):
    p[i][0] += min(p[i-1][1], p[i-1][2])
    p[i][1] += min(p[i-1][0], p[i-1][2])
    p[i][2] += min(p[i-1][0], p[i-1][1])

print(min(p[-1][0], p[-1][1], p[-1][2]))


''' 메모리 초과됐던 코드 '''
'''
N = int(input())

temp = []
prev = []
for i in range(N):
    if i == 0:
        temp = list(map(int, input().split())) # [26, 40, 88]
    else:
        temp2 = []
        input_num = list(map(int, input().split())) # [49, 60, 57]
        

        if i == 1:
            for j in range(3):
                for k in range(3):
                    if j != k:
                        temp2.append( [temp[j], input_num[k]] ) 
            temp = temp2
            
        else:
            max_value = 0
            for j in range(len(temp)): # 0~5
                index = prev.index(temp[j][1])
                #print('index = ', index)
                
                for k in range(3):
                    if k != index:
                        temp2.append( [ sum(temp[j]), input_num[k] ] )
            temp = temp2

        prev = input_num
        
    print(i, temp)
    print()


for i in range(len(temp)):
    temp[i] = sum(temp[i])

print(min(temp))

'''