diff options
Diffstat (limited to 'progs/a677.py')
-rw-r--r-- | progs/a677.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/progs/a677.py b/progs/a677.py new file mode 100644 index 0000000..73a09b9 --- /dev/null +++ b/progs/a677.py @@ -0,0 +1,8 @@ +def max_sum_rectangular_grid(grid, n) :
+ incl = max(grid[0][0], grid[1][0])
+ excl = 0
+ for i in range(1, n) :
+ excl_new = max(excl, incl)
+ incl = excl + max(grid[0][i], grid[1][i])
+ excl = excl_new
+ return max(excl, incl)
\ No newline at end of file |