class UnionFind def initialize(n) @size = Array.new(n, 1) @rank = Array.new(n, 0) @parent = [] (0..n).each do |i| @parent[i] = i end end def find(x) if @parent[x] == x x else @parent[x] = find(@parent[x]) end end def unite(x, y) x = find(x) y = find(y) return if x == y if @rank[x] < @rank[y] @parent[x] = y @size[y] += @size[x] else @parent[y] = x @size[x] += @size[y] @rank[x] += 1 if @rank[x] == @rank[y] end end def same?(x, y) find(x) == find(y) end def size(x) @size[find(x)] end end N, A, B = gets.split.map(&:to_i) X = gets.split.map(&:to_i) uf = UnionFind.new(N) l = 0 r = 1 while l <= r a = X[l] b = X[r] d = b - a if l != r && A <= d && d <= B uf.unite(l, r) end if d < A if r + 1 < N r += 1 else l += 1 end elsif B < d l += 1 else if r + 1 < N if X[r + 1] - a <= B r += 1 else l += 1 end else l += 1 end end end N.times do |i| puts uf.size(i) end