summaryrefslogtreecommitdiff
path: root/progs/a677.py
blob: 73a09b9eac8d948ec448667d95d125c5f6a36c58 (plain)
1
2
3
4
5
6
7
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)