Created
June 5, 2014 08:19
-
-
Save niyarin/8941fff0d4f180a17355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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