tj
2025-09-30 17:10:19
发布于:浙江
9阅读
0回复
0点赞
#include <iostream>
#include <vector>
#include <iostream>
using namespace std;
struct rst {
int x, y, z;
};
int main() {
int n, D;
cin >> n >> D;
vector<rst> r;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
r.push_back({x, y, z});
}
int maxp = 0;
for (int i = 0; i < n; i++) {
int sum = 0;
int cx = r[i].x;
int cy = r[i].y;
for (int j = 0; j < n; j++) {
int dx = abs(cx - r[j].x);
int dy = abs(cy - r[j].y);
if (dx + dy <= D) {
sum += r[j].z;
}
}
if (sum > maxp) {
maxp = sum;
}
}
cout << maxp << endl;
return 0;
}
这里空空如也
有帮助,赞一个