题解
2024-08-16 16:30:09
发布于:湖南
9阅读
0回复
0点赞
小暴力
//#include <cjdst.h>
#include <iostream>
#include <cstdio>
using namespace std;
int read(){
char c = getchar();
int x = 0, f = 1;
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)){
x = (x << 3) + (x << 1) + c - '0';
c = getchar();
}
return x * f;
}
void _write(int n){
if(n == 0) return;
_write(n / 10);
putchar(n % 10 + '0');
}
void write(int n, bool space = 0){
if(n < 0) putchar('-'), _write(-n);
else if(n == 0) putchar('0');
else _write(n);
if(space) putchar(' ');
}
int a[1145][1145];
int main(){
int m = read(), n = read(), x, y, z;
for(int i = 1; i <= n; i++){
x = read(), y = read(), z = read();
for(int j = max(0, x - m); j <= x + m; j++){
for(int k = max(0, y - m); k <= y + m; k++){
a[j][k] += z;//如果能炸到这个位置就加该垃圾数
}
}
}
int mx = 0;
for(int i = 0; i <= 1024; i++){
for(int j = 0; j <= 1024; j++){
mx = max(mx, a[i][j]);//求最大值
}
}
write(mx);
return 0;
}
这里空空如也
有帮助,赞一个