class Chukei attr_reader :x, :y, :friends def initialize(x, y) @x = x.to_f @y = y.to_f @friends = [] end def friend?(other) @friends.include?(other) end def denpa?(other) distance(other) <= 10 end def add_friend(other) @friends << other @friends |= other.friends end def distance(other) return Math.sqrt((@x - other.x)**2 + (@y - other.y)**2) end def max_dist_friend m = -1 @friends.each do |other| kyori = distance(other) m = kyori if kyori > m end return m end end n = gets.to_i chukei_list = [] n.times do chukei_list << Chukei.new(*(gets.split.map(&:to_i))) end chukei_list.each do |chukei| chukei_list.each do |other| unless chukei.friend?(other) if chukei.denpa?(other) chukei.add_friend(other) end end end end m = -1 chukei_list.each do |chukei| chu_m = chukei.max_dist_friend m = chu_m if m < chu_m end if m == -1 kotae = 2 else kotae = m + 2 end puts kotae