class Yukicoder attr_reader :red, :green, :blue def initialize @red, @green, @blue = gets.chomp.split(' ').map(&:to_i) min_count = 0 max_count = 10000000 create_count = 0 while min_count < max_count create_count = (min_count + max_count) / 2 if can_create?(create_count) min_count = create_count + 1 else max_count = create_count end end puts min_count - 1 end def can_create?(count) rest_count = 0 rest_count += [0, red - count].max / 2 rest_count += [0, green - count].max / 2 rest_count += [0, blue - count].max / 2 rest_count -= [0, count - red].max rest_count -= [0, count - green].max rest_count -= [0, count - blue].max rest_count >= 0 end end Yukicoder.new