What happens is A collides with B and immediately after collision B has some (horizontal) velocity in the same direction as A's original velocity.
Now B starts to ascend the slope, and we find how high it gets using conservation of energy i.e. mgh = ¹⁄₂mv²