meiguiOvO @ 2025-01-10 13:01:16
n = int(input()) matrix = [] for in range(n): matrix.append(list(map(int,input().split()))) s = [[0] * (n + 1) for in range(n + 1)] for i, row in enumerate(matrix): for j, x in enumerate(row): s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] - s[i][j] + x mx = float('-inf')
for x1 in range(1, n + 1): for y1 in range(1, n + 1): for x2 in range(1, n + 1): for y2 in range(1, n + 1): if x2 < x1 or y2 < y1: continue current_sum = s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1] mx = max(mx, current_sum) print(mx)
by XuYueming @ 2025-01-10 13:05:46
@meiguiOvO 希望更丰富的展现?阅读 Markdown 使用帮助、KaTeX 文档。
by x12345678901 @ 2025-01-10 13:20:25
以python的运行速度,不超时才怪。
by __Tao__ @ 2025-01-10 13:21:53
python的常数很大。
另外代码请框起来。
by meiguiOvO @ 2025-01-10 15:03:07
@Tao@Tao好的大佬 那有什么办法吗
by __Tao__ @ 2025-01-10 16:18:21
@meiguiOvO
改用 C++ ,还是尽量用 NOI 系列唯一指定语言吧