Problem list
Log in
#r03332 · Online Judge > GoldOJ

Collecting Ores

Silver II 2.0 s 256 MB

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
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code