cswork / OA打开练习工作台

FlexportOA #7

Matrix Traversal

估计中等可在线判题

考点(AI 标注)网格动规

Start from any cell in the first row of a 4×4 matrix; at each step, move to the next row in an adjacent column. Maximize the initial 100 energy minus the total of the values of the cells visited.

输入格式

4 lines, each containing 4 integers (0≤mat[i][j]<100).

输出格式

Output the maximum energy that can remain after reaching the last row; it may be negative.

样例 1

输入:

10 20 30 40
60 50 20 80
10 10 10 10
60 50 60 50

输出:

0

样例说明

A linear scan/dynamic programming solution follows directly from the rules; the examples have been checked one by one against an independently built oracle.