Created
October 20, 2017 14:52
Star
You must be signed in to star a gist
AtCoder ARC #047 B - 同一円周上
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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