Joe Root and Harry Brook smashed centuries as England defeated Sri Lanka in the third ODI to clinch the series 2-1.