South Africa’s Amla hits century to end lean spell