[BOJ] 주사위 쌓기

Date:

[BOJ] 주사위 쌓기

Problem URL : 주사위 쌓기

N = int(input())

dice = []

for i in range(N):
    dice.append(list(map(int, input().split())))

facing = [5, 3, 4, 1, 2, 0]
ans = 0

for i in range(1,7):
    bottom = i
    sum = 0
    for j in range(N):
        top = dice[j][facing[dice[j].index(bottom)]]
        if bottom == 6 or top == 6:
            if bottom == 5 or top == 5:
                sum += 4
            else:
                sum += 5
        else:
            sum += 6

        bottom = top

    if ans < sum:
        ans = sum

print(ans)

댓글