360笔试第一题,时间到了才写出来还没来得及粘贴,凉凉
dp = [0] * (n * m) for i in range(n): for j in range(m): cur = mat[i][j] * 6 - (mat[i][j] - 1) * 2 if j > 0: left = 2 * min(mat[i][j], mat[i][j - 1]) else: left = 0 if i > 0: up = 2 * min(mat[i][j], mat[i - 1][j]) else: up = 0 dp[i * n + j] = cur + dp[i * n + j - 1] - left - up print(dp[-1])
#360公司##笔试题目##秋招#