Олимпиадный тренинг

Задача 39809. DV-2022


Задача

Темы: ЕГЭ
The square is lined with N × N cells (1 < N < 30). The Executor Robot can move around the cells by performing one of two commands in one move: right or down. right  command moves to the neighboring right cell, down – to the lower one. 
The square is bounded by outer walls. There can also be internal walls between adjacent square cells. The robot cannot pass through walls. 
Before each start of the Robot, in each cell of the square there is a coin with a value from 1 to 100. Having visited the cell, the Robot takes the coin with him; this also applies to the start and end cells of the Robot's route.
Determine the maximum and minimum amounts of money that the Robot can collect by going from the upper left cell to the lower right. In your answer, indicate two numbers – first the maximum amount, then the minimum.
Both numbers are specified on the same line, separated by one space.

The source data is a spreadsheet of  N × N, each cell of which corresponds to a square cell. Inner & nbsp;  outer walls are marked with thick lines.
For the specified input, the answer must be a pair of numbers
38 22