On an $N \times M$ grid you move only right or down from the top-left $(1,1)$ to the bottom-right $(N,M)$. Each cell holds an ore (1) or is empty (0). Print the maximum number of ores you can collect along a path.
Input
First line $N$ and $M$; then $N$ rows of $M$ values, each $0$ or $1$ ($1 \le N, M \le 200$).
Output
Print the maximum number of ores collected.
Example 1
Input
5 4 0 1 0 0 0 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0
Output
4
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.