Advertisement
nq1s788

Untitled

Sep 7th, 2023
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. n = int(input())
  2. mx = [[0] for i in range(n + 1)] for j in range(n + 1)
  3. for i in range(n):
  4.     a = list(map(int, input().split()))
  5.     for j in range(i + 1, n + 1):
  6.         mx[i][j] = a[j - i - 1]
  7.         mx[j][i] = a[j - i - 1]
  8. w = [0] * (n + 1)
  9. for i in range(1, n + 1):
  10.     w[i] = mx[0][i]
  11.     for j in range(1, i):
  12.         w[i] = max(w[i], w[j] + mx[j][i])
  13. print(w[n])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement