Skip to content

Instantly share code, notes, and snippets.

@iorionda
Created September 2, 2015 07:35
Show Gist options
  • Save iorionda/826ebf59a07487a3a0d8 to your computer and use it in GitHub Desktop.
Save iorionda/826ebf59a07487a3a0d8 to your computer and use it in GitHub Desktop.
x=y=0.0
gets.to_i.times do
t,s=gets.split.map(&:to_i)
case t
when 1
x+=s
when 2
y+=s
when 3
x,y=x-s*x/(x+y),y-s*y/(x+y)
end
end
puts (100*y/x+y).to_i
# 4
# 1 50
# 2 55
# 3 15
# 1 20
# => 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment