显示代码纯文本
#include <stdio.h>
int d,n,i,a[3][25],x,y,k,b[130][130],e[2],f,m,j,ij,max,p;
int main()
{
freopen("wireless.in","r",stdin);
freopen("wireless.out","w",stdout);
scanf("%d",&d);
scanf("%d",&n);
memset(a,0,sizeof(a));
for(i=0;i<n;i++)
scanf("%d %d %d",&a[0][i],&a[1][i],&a[2][i]);
memset(b,0,sizeof(b));
for(i=0;i<n;i++)
{
if(a[0][i]-d<0)
e[0]=0;
else e[0]=a[0][i]-d;
if(a[0][i]+d>128)
m=128;
else m=a[0][i]+d;
if(a[1][i]-d<0)
e[1]=0;
else e[1]=a[1][i]-d;
if(a[1][i]+d>128)
f=128;
else f=a[1][i]+d;
for(j=e[0];j<=m;j++)
for(ij=e[1];ij<=f;ij++)
b[j][ij]+=a[2][i];
}
max=0;
p=0;
for(i=0;i<=128;i++)
for(j=0;j<=128;j++)
{
if(b[i][j]>max)
{
max=b[i][j];
p=1;
}
else
if(b[i][j]==max)
p++;
}
printf("%d %d",p,max);
return 0;
}