AOJ 0065 - Trading
last_m = {} this_m = {} while s = gets break if s == "\n" data = s.split(",").map{|e| e.to_i } last_m[data[0]] = 0 unless last_m.key?(data[0]) last_m[data[0]] += 1 end while s = gets break if s == nil data = s.split(",").map{|e| e.to_i } this_m[data[0]] = 0 unless this_m.key?(data[0]) this_m[data[0]] += 1 end last_m.select{|k, v| this_m.member?(k) }.sort_by{|k, v| k }.each{|k, v| puts "#{k} #{v+this_m[k]}" }
*1:本当に便利