QOJ.ac

QOJ

Puntuación total: 100

#9473. 益智游戏

Estadísticas

从前有一只小狗 YK。有一天,他去了一家古董店,被一幅美丽的画深深吸引。YK 非常喜欢它,但他没有钱买。他恳求店主 Bob 能否不花钱就得到它。

幸运的是,Bob 很喜欢益智游戏。他答应如果 YK 能帮他解决一个益智游戏,就免费把画送给 YK。

Bob 画了一个拼图板,这是一个由 $n \times m$ 个单元格组成的 $n \times m$ 矩阵。每个单元格中都有一个整数。子矩阵是指拼图板上连续的一部分(整个拼图板也可以称为子矩阵)。子矩阵的值是指该子矩阵中所有单元格内整数的和。值最大的子矩阵被称为“最大子矩阵”。Bob 想要通过选择板上的一个单元格并将其中的整数修改为 $P$,来使最大子矩阵的值尽可能小。如果这种修改没有任何好处,他也可以选择不修改任何单元格。

在这种情况下,YK 需要计算出 Bob 能得到的最大子矩阵的最小值。

输入格式

测试用例不超过 120 组,其中 $n \ge 50$ 或 $m \ge 50$ 的测试用例最多 3 组。

每个测试用例的第一行包含三个整数,即上述的 $n$、$m$ 和 $P$ ($1 \le n, m \le 150, -1000 \le P \le 1000$)。

接下来有 $n$ 行。每行包含 $m$ 个整数 $x_1, x_2, \dots, x_m$ ($-1000 \le x_i \le 1000, i = 1 \dots m$)。这 $n$ 行即为拼图板上 $n \times m$ 个单元格中的整数。

输出格式

对于每个测试用例,输出 Bob 能得到的最大子矩阵的最小值。

样例

输入 1

3 3 -10
-100 4 4
4 -10 4
4 4 1

输出 1

8

输入 2

3 3 -1
-2 -2 -2
-2 -2 -2
-2 -2 -2

输出 2

-2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.