Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active January 25, 2016 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/a5de9a7fd01bf013bb32 to your computer and use it in GitHub Desktop.
Save whatalnk/a5de9a7fd01bf013bb32 to your computer and use it in GitHub Desktop.
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