@x=[];a=[];@t=[] n,k = gets.chomp.split(" ").map(&:to_i) @x+=gets.chomp.split(" ").map(&:to_i) a+=gets.chomp.split(" ").map(&:to_i) @hash = Hash[*([@x,a].transpose.flatten)] p=@x[k-1] b=a[k-1] def f(p,w) b = @hash[p] zzz = p+w*b zzz1 = p+(-1*w*b) @x.each do |elm| if zzz1 > zzz if elm >=zzz and zzz1 >= elm if @t.any? {|w| w == elm } next else @t<= elm and elm >= zzz1 if @t.any? {|w| w == elm } next else @t<