0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:11:58 +00:00

P2280 [HNOI2003]激光炸弹

R63978323
This commit is contained in:
Baoshuo Ren 2021-11-30 19:11:14 +08:00 committed by Baoshuo Ren
parent 3a85a14a17
commit 378581f5fb
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
Luogu/P2280/P2280.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int n, m, x, y, v, ans, g[5005][5005];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> x >> y >> v;
g[x + 1][y + 1] = v;
}
for (int i = 1; i <= 5001; i++) {
for (int j = 1; j <= 5001; j++) {
g[i][j] += g[i][j - 1] + g[i - 1][j] - g[i - 1][j - 1];
}
}
for (int i = m; i <= 5001; i++) {
for (int j = m; j <= 5001; j++) {
ans = std::max(ans, g[i][j] - g[i - m][j] - g[i][j - m] + g[i - m][j - m]);
}
}
cout << ans << endl;
return 0;
}