cswork / OA打开练习工作台

eBayOA #7

Max Valid Expression in Puzzle Matrix

估计中等可在线判题

考点(AI 标注)字符串模拟/实现

An expression starts at any digit cell and can only go straight right or straight down, without turning. The characters must alternate as digit, +/-, digit; a single digit is also a valid expression. Find the maximum value of a valid path expression.

输入格式

h,w (1..100, hw≤10000); the character matrix contains only digits, +, and −, with at least one digit. The size limits are site supplements.

输出格式

Output the maximum value.

样例 1

输入:

1 5
9-1+8

输出:

16

样例 2

输入:

5 1
8
+
9
+
9

输出:

26

样例 3

输入:

2 3
1+2
3-4

输出:

4