EG1 激光炸弹
题意:给你n个点的坐标及权值,用r * r的范围最大覆盖是多少
题解
#include <iostream>
#include <algorithm>
using namespace std;
int n, r;
int ta, tb;
int x, y, w;
int sum[5005][5005];
int ans = 0;
int main()
{
cin >> n >> r;
ta = r;
tb = r;
for (int i = 0; i < n; i++)
{
cin >> x >> y >> w;
x++;
y++;
sum[x][y] += w;
ta = max(ta, x);
tb = max(tb, y);
}
for (int i = 1; i <= ta; i++)
for (int j = 1; j <= tb; j++)
sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
for (int i = r; i <= ta; i++)
for (int j = r; j <= tb; j++)
ans = max(ans, sum[i][j] - sum[i - r][j] - sum[i][j - r] + sum[i - r][j - r]);
cout << ans << endl;
return 0;
}
作者:LightAc
出处:https://www.cnblogs.com/lightac/
联系:
Email: dzz@stu.ouc.edu.cn
QQ: 1171613053
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。