#P2045. 方格取数加强版
方格取数加强版
Description
Given an matrix. Each cell contains a non-negative integer (). Starting from , you may move only right or down and finally reach . Every time you arrive at a cell, you take the number in that cell and the cell’s value becomes . Repeat this walk a total of times. Find the maximum possible sum of the values collected over the walks.
Input Format
The first line contains two integers (, ).
The next lines each contain integers, denoting the value of each cell in the matrix.
Output Format
Output a single integer, the maximum sum.
3 1
1 2 3
0 2 1
1 4 2
11
Hint
The value in each cell does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号