



- func bestCoordinate(towers [][]int, radius int) []int {
- maxDistance, ans := 0, make([]int, 2)
- for i := 0; i < 51; i++ {
- for j := 0; j < 51; j++ {
- sum := 0
- for _, tower := range towers {
- d := math.Hypot(float64(tower[0]-i), float64(tower[1]-j))
- if d <= float64(radius) {
- sum += int(float64(tower[2])/(1 + d))
- }
- }
- if sum > maxDistance {
- maxDistance = sum
- ans = []int{i,j}
- }
- }
- }
- return ans
- }