luogu#P4013. 数字梯形问题

    ID: 2964 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化图论建模费用流网络流与线性规划 24 题

数字梯形问题

Problem Description

Given a number trapezoid with nn rows as shown in the figure.

The first row of the trapezoid contains mm numbers. Starting from each of the mm numbers in the top row, you may move at each step to the lower-left or lower-right adjacent number, forming a path from the top to the bottom of the trapezoid.

Respect the following rules respectively:

  1. The mm top-to-bottom paths are pairwise disjoint (no common nodes or edges).
  2. The mm top-to-bottom paths may intersect only at numeric nodes (shared nodes allowed, shared edges not allowed).
  3. The mm top-to-bottom paths may intersect at numeric nodes or along edges (both nodes and edges may be shared).

Input Format

The first line contains two positive integers mm and nn, denoting that the first row of the number trapezoid has mm numbers and there are nn rows in total. The next nn lines give the numbers in each row of the trapezoid.

Row 11 has mm numbers, row 22 has m+1m+1 numbers, and so on.

Output Format

Output the maximum total sum computed under Rule 11, Rule 22, and Rule 33, respectively, one maximum sum per line.

2 5
2 3
3 4 5
9 10 9 1
1 1 10 1 1
1 1 10 12 1 1
66
75
77

Hint

1m,n201 \leq m,n \leq 20.

Translated by ChatGPT 5