显示代码纯文本
#include <iostream>
#include <fstream>
using namespace std;
int g[129][129], n, d, ans1 = 0, ans2 = 0;
main()
{
ifstream fin("wireless.in");
ofstream fout("wireless.out");
#define cin fin
#define cout fout
ios::sync_with_stdio(false);
cin >> d >> n;
for (int i = 1; i <= n; ++i){
int a, b, c, x1, x2, y1, y2;
cin >> a >> b >> c;
x1 = max(a - d, 0);
y1 = max(b - d, 0);
x2 = min(a + d, 128);
y2 = min(b + d, 128);
for (int j = x1; j <= x2; ++j)
for (int k = y1; k <= y2; ++k)
g[j][k] += c;
}
for (int i = 0; i < 129; ++i)
for (int j = 0; j < 129; ++j)
if(ans2 < g[i][j]){
ans2 = g[i][j];
ans1 = 1;
}
else if(ans2 == g[i][j])
ans1++;
cout << ans1 << ' ' << ans2;
}