Skip to content

Instantly share code, notes, and snippets.

@Eric-Bro
Created April 12, 2012 09:44
Show Gist options
  • Save Eric-Bro/2365947 to your computer and use it in GitHub Desktop.
Save Eric-Bro/2365947 to your computer and use it in GitHub Desktop.
Problem PB-2
Manager = Struct.new(:time, :cnt)
n = gets().to_i
times = $stdin.readline.split.each{|z| z = z.to_i}.sort!{|x,y| y <=> x}
managers = Array.new(3){|x| Manager.new(0,0)}
while (times.count > 0) do
managers.sort!{|x,y| x.time <=> y.time}[0].time += times.shift.to_i
managers[0].cnt += 1
end
managers.each{|x| print x.cnt.to_s + " "}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment