Create a gist now

Instantly share code, notes, and snippets.

square869120Contest #1 (AtCoder)
n = gets.chomp.to_f
duration = 18 * 60.0
puts duration / (n - 1)
h, w, n = gets.chomp.split(" ").map(&:to_i)
if n.odd? then
puts -1
exit
end
berries = []
n.times do
berries << gets.chomp.split(" ").map(&:to_i)
end
res = []
(0..w).each do |i|
part = 0
berries.each do |b|
if b[1] * i - b[0] * w < 0 then
part += 1
end
end
if part == n / 2 then
res << [i, h]
end
end
(0...h).each do |i|
part = 0
berries.each do |b|
if b[1] * w - b[0] * i < 0 then
part += 1
end
end
if part == n / 2 then
res << [w, i]
end
end
if res.empty? then
puts -1
else
res.sort.each do |i|
puts "(#{i[0]},#{i[1]})"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment