Skip to content

Instantly share code, notes, and snippets.

@niyarin
Created June 5, 2014 08:19
Show Gist options
  • Save niyarin/8941fff0d4f180a17355 to your computer and use it in GitHub Desktop.
Save niyarin/8941fff0d4f180a17355 to your computer and use it in GitHub Desktop.
n = input()
note = [[-1 for i in range(n)] for j in range(n)]
data = []
for i in range(n):
data.append(raw_input().split(" "))
print data
def Foo(x,y):
if y >= n-1:
return int(data[y][x])
if note[x][y] != -1:
return note[x][y]
note[x][y] = max(Foo(x,y+1),Foo(x + 1,y + 1))
return note[x][y] + int(data[y][x])
print Foo(0,0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment