class Yukicoder DRY = 0 WET = 1 MOIST = 2 def initialize n = gets.to_i a = gets.chomp.split.map(&:to_i) dry = Array.new(n, false) wet = Array.new(n, false) moist = Array.new(n, false) answer = Array.new(3, 0) a.sort_by{|i| 10 ** 5 * i.abs + i}.each_cons(2).with_index(0) do |i, j| if i[0] + i[1] < 0 && !dry[j] && !dry[j+1] answer[DRY] += 1 dry[j] = true dry[j+1] = true end if i[0] + i[1] == 0 && !moist[j] && !moist[j+1] answer[MOIST] += 1 moist[j] = true moist[j+1] = true end end a.sort_by{|i| 10 ** 5 * i.abs - i}.each_cons(2).with_index(0) do |i, j| if i[0] + i[1] > 0 && !wet[j] && !wet[j+1] answer[WET] += 1 wet[j] = true wet[j+1] = true end end p answer.join(' ') end end Yukicoder.new