box_width = gets.to_i box_num = gets.to_i blocks = gets.split.map(&:to_i) count_box_num = 0 blocks.sort! blocks.map{|s| box_width -= s if box_width < 0 puts count_box_num return else count_box_num += 1 end }