South Africa's Sibanye-Stillwater has agreed to buy Lonmin, valuing the troubled platinum producer at about $382.47 million.