Create SRM 583 Div 2 250 p

My solution for the 250 points problem in SRM 583, Div 2