pythondef solve(N, scores):
last_score = scores[0]
for i in range(1, N):
next_score = [
max(last_score[1], last_score[2]) + scores[i][0],
max(last_score[2], last_score[0]) + scores[i][1],
max(last_score[0], last_score[1]) + scores[i][2],
]
last_score = next_score
return max(last_score)