Given a grid of height h and width w, you are asked to calculate the maximum sum one might obtain by moving from top to bottom, where on each step itβs only allowed to move to the below adjacent 3 cells. In other words, being at position (r, c), you can move to positions: (r + 1, c - 1), (r + 1, c), and (r + 1, c + 1). Thatβs why we call it a falling sum - as we fall from the top to the very bottom of the grid. Find the maximum sum of the path.
γ €
o
γ €
γ €
βοΈ
β¬οΈ
βοΈ
γ €
γ €
γ €
γ €
γ €
γ €
γ €
γ €
γ €
Input
The first line of the input contains two integers h and w (1 β€ h, w β€ 100).
The next h lines contain w numbers (-100 β€ β€ 100) representing the values of the grid at row r and column c.
Output
The program should print the maximum possible sum obtained among all the possible falling paths.