• + 0 comments

    ruby:

    gets.to_i.times do
        n,k = gets.strip.split.map &:to_i
        a = gets.strip.split.map &:to_i
        max, prev = (1..n).reduce(:+), 0
        for i in 0...n do
            if a[i] > k
                max -= (1..prev).reduce(:+) || 0
                prev = 0
            else
                prev +=1 end
            i += 1 end
        max -= (1..prev).reduce(:+) || 0
        puts max end