LearnPy Hub
← Arena
IntermediateRating 1300

Cheapest Path in a Grid

Move right or down from the top-left to the bottom-right cell; minimise the sum of the numbers on the path.

Input

r c, then r lines.

Output

A number.

Sample 1

Input
3 3
1 3 1
1 5 1
4 2 1
Output
7

Sample 2

Input
2 3
1 2 3
4 5 6
Output
12
solution.py
Output appears here
Cheapest Path in a Grid · Python Arena problem · LearnPy Hub