80pts,不知道错哪里了
查看原帖
80pts,不知道错哪里了
779309
sort_12470楼主2023/7/12 09:39

RT

#include<bits/stdc++.h>
using namespace std;
const int M = 128 + 40 + 9;
int d, n, cnt = 1, x, y, k;
long long maxx = -1;
long long city[M][M] = {0};
int main(){
	//freopen("P2038_1.in", "r", stdin);
	scanf("%d%d", &d, &n);
	while(n--){
		scanf("%d%d%d", &x, &y, &k);
		x += 20;
		y += 20;
		int L = max(x - d, 0), R = min(x + d, 148), U = max(y - d, 0), D = min(y + d, 148);
		for(int r = L; r <= R; ++r)
			for(int w = U; w <= D; ++w)
				city[r][w] += k;
	}
	for(int i = 0; i <= 148; ++i)
		for(int j = 0; j <= 148; ++j){
			if(city[i][j] > maxx){
				maxx = city[i][j];
				cnt = 1;
			}
			else if(city[i][j] == maxx)
				cnt++;
		}
	printf("%d %llu", cnt, maxx);
	return 0;
}
2023/7/12 09:39
加载中...