Created
October 9, 2018 09:51
-
-
Save whatalnk/2525c85b63b6cf0eb5ef926c792ce6b3 to your computer and use it in GitHub Desktop.
AtCoder ABC #112 C
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 | |
ax = [] | |
ay = [] | |
ah = [] | |
gx, gy, gh = -1, -1, -1 | |
n.times do | |
x, y, h = gets.chomp.split(" ").map(&:to_i) | |
ax << x | |
ay << y | |
ah << h | |
gx, gy, gh = x, y, h if h > 0 | |
end | |
ans = [] | |
0.upto(100) do |cx| | |
0.upto(100) do |cy| | |
ch = gh + (gx - cx).abs + (gy - cy).abs | |
ch = [ch, 0].max | |
flag = true | |
n.times do |i| | |
x = ax[i] | |
y = ay[i] | |
h = ah[i] | |
hh = ch - (x - cx).abs - (y - cy).abs | |
hh = [hh, 0].max | |
if h != hh | |
flag = false | |
end | |
end | |
if flag | |
ans << [cx, cy, ch] | |
end | |
end | |
end | |
if ans.length == 1 | |
puts ans[0].join(" ") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment