1 条题解
-
0
求解多个 的矩阵和,利用二维前缀和。
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e3 + 5; int t, n = 5001, r, g[N][N], ans; int main() { cin >> t >> r; int x, y, z; for (int i = 1; i <= t; i++) cin >> x >> y >> z, g[x + 1][y + 1] += z; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1]; for (int i = r; i <= n; i++) for (int j = r; j <= n; j++) { int s = g[i][j] - g[i - r][j] - g[i][j - r] + g[i - r][j - r]; ans = max(ans, s); } cout << ans << endl; }
- 1
信息
- ID
- 1436
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 10
- 标签
- 递交数
- 9
- 已通过
- 1
- 上传者