class Yukicoder def initialize @d = gets.to_i @week = gets.chomp @week += gets.chomp answer = 0 0.upto(@week.size-1) do |i| temp = @week.dup set_renkyu(i) answer = [answer, get_renkyu].max @week = temp.dup end puts answer end def set_renkyu(i) count = 0 while @week[i] == 'x' && count <= @d @week[i] = 'o' i += 1 count += 1 end end def get_renkyu renkyu = 0 max_renkyu = 0 @week.chars do |ch| if ch == 'o' renkyu += 1 else max_renkyu = [max_renkyu, renkyu].max renkyu = 0 end end max_renkyu = [max_renkyu, renkyu].max max_renkyu end end Yukicoder.new