Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- mx = [[0] for i in range(n + 1)] for j in range(n + 1)
- for i in range(n):
- a = list(map(int, input().split()))
- for j in range(i + 1, n + 1):
- mx[i][j] = a[j - i - 1]
- mx[j][i] = a[j - i - 1]
- w = [0] * (n + 1)
- for i in range(1, n + 1):
- w[i] = mx[0][i]
- for j in range(1, i):
- w[i] = max(w[i], w[j] + mx[j][i])
- print(w[n])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement