#include <bits/stdc++.h>
using namespace std;
long long d, n, x[21], y[21], k[21], ans, sum;
int main(){
cin >> d >> n;
for(int i = 1; i <= n; i++){
cin >> x[i] >> y[i] >> k[i];
}
for(int i = d - 1; i <= 128 - d;i++){
for(int j = d - 1; j <= 128 - d; j++){
long long maxx = 0;//记录能够覆盖的最多公共场所
for(int l = 1; l <= n; l++){
if(abs(x[l] - i) <= d && abs(y[l] - j) <= d){
maxx += k[l];//如果能够覆盖加进maxx
}
}
if(maxx == ans){
sum ++;//有相同的点就方案++
}
if(maxx > ans){
ans = maxx;
sum = 1;//如果方案并不是最优就重新记录
}
// cout << "maxx = " << maxx << '\n';
}
}
cout << sum << " " << ans;
return 0;
}
这个代码样例过了,自己给的数据也没问题,交上去就是WA三个点,哪位大佬帮忙调一下