Optimizing Box Weights Hackerrank Solution In C