Turtle
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
There is a turtle in the left top corner of rectangular table of size . Each cell of the table contains some amount of acid. Turtle can move right or down, its route terminates in right bottom cell of the table.
Each milliliter of acid brings turtle some amount of damage. Find the smallest possible value of damage that will receive a turtle after a walk through the table.
Input
First line contains two positive integers and , no more than — the sizes of the table. Then lines are given, each contains integers — the description of the table, each number given the amount of acid in the cell (in milliliters).
Output
Print the minimum possible damage for the turtle.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 10K
Acceptance rate 43%