You can buy the ticket you need from the kiosks (or vending machines) right at the entrance to the airport RER station. The line is RER B. Current cost is €10.30 per ticket, one way. Similarly, if you want to take the RER back to CDG on your departure day, buy your ticket at the RER B station.