Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created October 20, 2017 14:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save whatalnk/87a0c90c77753b6f90be5590d196fbf3 to your computer and use it in GitHub Desktop.
AtCoder ARC #047 B - 同一円周上
N = gets.chomp.to_i
x = []
y = []
xx = []
yy = []
N.times do
x_, y_ = gets.chomp.split(" ").map(&:to_i)
x << x_
y << y_
xx << x_ + y_
yy << x_ - y_
end
mx = [xx.min, xx.max]
my = [yy.min, yy.max]
d = [mx[1] - mx[0], my[1] - my[0]].max / 2
2.times do |i|
[-1, 1].each do |j|
pxx = mx[i] + d * j
pyy = my[i] + d * j
px = (pxx + pyy) / 2
py = (pxx - pyy) / 2
if (0...N).all?{|i| (px - x[i]).abs + (py - y[i]).abs == d}
puts "#{px} #{py}"
exit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment