1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<queue> 5 #include<stack> 6 #include<vector> 7 #include<algorithm> 8 #include<string> 9 #include<cstring> 10 #include<iomanip> 11 #include<bitset> 12 #include<cstdlib> 13 using namespace std; 14 int d,n,x,y,k,maxn,p; 15 int t[250][250]; 16 int main() 17 { 18 freopen ("wireless.in","r",stdin); 19 //freopen ("wireless.out","w",stdout); 20 scanf ("%d%d",&d,&n); 21 for (int i=1;i<=n;i++) 22 { 23 scanf ("%d%d%d",&x,&y,&k); 24 t[x][y]=k; 25 } 26 for (int i=0;i<=222//here;i++) 27 for (int j=0;j<=222;j++) 28 { 29 if (i>0&&j>0) t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1]; 30 if (i>0&&j==0) t[i][j]+=t[i-1][j]; 31 if (i==0&&j>0) t[i][j]+=t[i][j-1]; 32 } 33 for (int i=0;i<=128;i++) 34 for (int j=0;j<=128;j++) 35 if (i+d<=222&&j+d<=222//and here) 36 { 37 int a=t[i+d][j+d]; 38 if (i-d-1>=0) a-=t[i-d-1][j+d]; 39 if (j-d-1>=0) a-=t[i+d][j-d-1]; 40 if (i-d-1>=0&&j-d-1>=0) a+=t[i-d-1][j-d-1]; 41 if (a>maxn) {maxn=a;p=1;} 42 else if (a==maxn) p++; 43 } 44 printf ("%d %d",p,maxn); 45 return 0; 46 }
时间: 2024-10-07 23:13:58