solved the maximum weight difference